COPY_ATTRS

The COPY_ATTRS command copies one or more attributes from one layer of features to another. The attributes are copied spatially between feature types, like copying point attributes to the area features those points are contained in, etc. Not every combination of feature types is supported for copying. If you choose a combination that is not supported (like LINES to LINES) you will get an error message.

The following parameters are used by the COPY_ATTRS command:

  • LAYER1_FILENAME - full path and filename of the loaded vector layer to copy attributes from. You can also pass in the full description of the loaded layer to use in case you want to use a layer not loaded from a file. Wildcards (i.e. '*' and '?') are supported in the filename, so to match all layers, use *.
  • FROM_TYPE - defines the type of features to copy attributes from. The following values are supported:
    • AREAS - copy attributes from areas
    • LINES - copy attributes from lines
    • POINTS - copy attributes from points
  • LAYER2_FILENAME - full path and filename of the loaded vector layer to copy attributes to. You can also pass in the full description of the loaded layer to use in case you want to use a layer not loaded from a file. Wildcards (i.e. '*' and '?') are supported in the filename, so to match all layers, use *.
  • TO_TYPE - defines the type of features to copy attributes to. The following values are supported:
    • AREAS - copy attributes to areas
    • LINES - copy attributes to lines
    • POINTS - copy attributes to points
  • ATTR_TO_COPY - specifies the name of an attribute to copy from the "from" features to the "to" features. You can include multiple instances of this parameter to copy multiple attributes. In addition to attribute names, you can specify <Feature Name> to copy the feature display label.
  • MAX_DIST - when copying from LINES to POINTS or POINTS to LINES, specifies the maximum distance that a point can be from the closest line and still have the attributes copied.
  • ENCLOSED_ONLY - when copying attributes from AREAS to LINES, specifies whether or not the line features have to be completely inside the areas. Use ENCLOSED_ONLY=YES to specify that the lines must be completely inside the areas.
  • MULTI_AREA - specifies how to handle assigning attributes from AREAS to POINTS or LINES when the point/line feature is inside multiple area features. The following values are supported:
    • NONE - don't copy the attributes from any of the containing areas if there are more than one
    • ALL - copy the attributes of every area containing the point/line feature
    • ALL_SORT - copy the attributes of every area containing the point/line feature. If there are multiple copies of the same attribute (including existing values), separate the values with a comma and sort them alphabetically. So if there are values of an attribute 'South St', '83 Pine', and 'Main', the result would be '83 Pine,Main,South St'. The sorting is done without regard to case.
    • FIRST - only copy the attributes of the topmost containing area to the point/line feature
  • MULTI_POINT - specifies how to handle assigning attributes from POINTS to AREAS or LINES when there are multiple points inside a single area or near a line. The following values are supported:
    • NONE - don't copy the attributes from any of the points in the area/line feature
    • ALL - copy the attributes of every point in the area or near the line to the area/line feature
    • ALL_CLONE - if multiple exist clone the feature for each matching feature
    • FIRST - (to AREAS only) only copy the attributes of the first point in the area to the area
    • CLOSEST - (to LINES only) only copy the attributes of the closest point to the line to the line
    • MIN - (to LINES only) use the minimum value of the attribute encountered
    • MAX - (to LINES only) use the maximum value of the attribute encountered
  • AREA_COVERAGE - specifies how covered a "to" area has to be by a "from" area for the attributes to be copied. The following values are supported:
    • COMPLETE - the "to" area has to be complete inside the "from" area
    • PARTIAL - the "to" area has to be covered at least some by the "from" area
    • CENTROID - the "to" area centroid has to be inside the "from" area. This option is the fastest but may result in some areas getting attributes that aren't covered at all if the centroid is outside of the "to" area.
    • MOST - the "to" area has to be at least half covered by the "from" area
  • EQUAL_ATTR - specifies an attribute that must be equal between two features in order to be a possible match for copying other attributes. See special Attribute Name parameter details for allowed attribute names. You can include multiple EQUAL_ATTR parameters on a command to require multiple attributes be equal.

SAMPLE

GLOBAL_MAPPER_SCRIPT VERSION="1.00"
/* Copy all loaded area attributes to the points in the area */
COPY_ATTRS LAYER1_FILENAME="*" FROM_TYPE="AREAS" LAYER2_FILENAME="*" TO_TYPE="POINTS"