Cropping Operations to Polygons/Areas

Most commands that support cropping can crop to a polygon using the POLYGON_CROP_FILE and related parameters. With these you can specify to crop the operation to area features from some vector file or already loaded layers. See below for a detailed description of the parameters that are related to polygon cropping:

  • POLYGON_CROP_FILE - specifies the full path and filename or loaded layer description of a vector file/loaded layer containing one or more polygon features to which the operation should be cropped. If multiple polygons are found in the specified file the polygon which has the largest intersection with the data to be combined will be used as the crop polygon (see POLYGON_CROP_USE_ALL or POLYGON_CROP_USE_EACH for exceptions).
  • POLYGON_CROP_FILE_PROJ - specifies the projection to use for the POLYGON_CROP_FILE. Use if the file doesn't have an associated projection file. See special Projection Specification for instructions.
  • POLYGON_CROP_NAME - specifies the name of a polygon shape previously defined using the DEFINE_SHAPE command to which the export should be cropped. The coordinates in the shape need to have been provided in whatever projection the new terrain layer will be in (i.e. the current projection). If you want to crop to any area features that are selected with the Digitizer Tool in the user interface rather than a defined polygon, use POLYGON_CROP_NAME="SELECTED".
  • POLYGON_CROP_USE_ALL - specifies that if a POLYGON_CROP_FILE is specified that contains multiple polygons, the operation will be cropped to all polygons in that file rather than just the best-fit polygon.
  • POLYGON_CROP_USE_EACH - specifies that if a POLYGON_CROP_FILE is specified that contains multiple polygons, the operation will generate a separate export for each polygons in that file rather than just the best-fit polygon. See the POLYGON_CROP_BBOX_ONLY and POLYGON_CROP_NAME_ATTR options for naming and other options when using this parameter. Use POLYGON_CROP_USE_EACH=YES to enable. This parameter also works with FEATHER_BLEND_EDGES. Use POLYGON_CROP_USE_EACH=YES with FEATHER_BLEND_POLY_FILE or FEATHER_BLEND_POLY to feather the edges of multiple polygons.
  • POLYGON_CROP_EXCLUDE - specifies that the crop areas are actually regions to exclude from the export rather than include. If you add POLYGON_CROP_EXCLUDE=YES to the command the results will contain everything outside the crop areas but within the full export bounds.
  • POLYGON_CROP_COMBINE_DUPS - specifies that if a POLYGON_CROP_FILE is specified that contains multiple polygons and POLYGON_CROP_USE_EACH is set, whether or not polygons with duplicate values for the attribute used for filenaming will be combined into a single export or split into separate exports. The default is POLYGON_CROP_COMBINE_DUPS=YES.
  • POLYGON_CROP_BBOX_ONLY - specifies that if the POLYGON_CROP_USE_EACH parameter is specified that each export should just be cropped to the bounding box of each polygon rather than the actual boundary of the polygon. Use POLYGON_CROP_BBOX_ONLY=YES to enable only cropping to the bounding box.
  • POLYGON_CROP_GRID_ONLY - specifies that any crop polygon(s) are used only to determine which tile/grid cells will be exported. For each tile/grid cell that intersects a crop polygon, the full tile/grid cell will be exported. Use POLYGON_CROP_GRID_ONLY=YES to enable.
  • POLYGON_CROP_INT_DATA_BOUNDS - control how the bounding box for the export is determined if a crop polygon is specified. If this option is disabled, the export bounds will be the bounds of the crop area(s), even if they extend outside the data bounds, unless you explicitly specified a bounding box in the other parameters (i.e. LAYER_BOUNDS, GLOBAL_BOUNDS, etc.). If the option is enabled, the export bounds will be the intersection of the crop area bounds and the non-cropped bounding box (i.e. full data bounds or specified bounds in other parameter). This parameter is enabled by default, use POLYGON_CROP_INT_DATA_BOUNDS=NO to disable.
  • POLYGON_CROP_NAME_ATTR - used to control the filenames generated when cropping to multiple polygons using the POLYGON_CROP_USE_EACH parameter. See special Attribute Name parameter details. This value will be appended to any filename specified in the EXPORT FILENAME parameter. If no value is provided, the exported files will be sequentially numbered.
  • POLYGON_CROP_FOLDER_ATTR - used to control the filenames generated when cropping to multiple polygons using the POLYGON_CROP_USE_EACH parameter. See special Attribute Name parameter details.
  • POLYGON_CROP_FILENAME_SUFFIX - specifies the text to insert in the output filename just before the file extension when cropping to polygons. For example, if you add POLYGON_CROP_FILENAME_SUFFIX="_out", the original FILENAME was "my_file_.dem" and the value from the polygon was "A1", you would get an output filename of "my_file_A1_out.dem".
  • POLYGON_CROP_COMPARE_STR - specifies a compare string to use to filter out the areas in the polygon crop file. See the COMPARE_STR parameter for the EDIT_VECTOR script command for details.

EXAMPLE

GLOBAL_MAPPER_SCRIPT VERSION=1.00
EXPORT_RASTER FILENAME="C:\TEMP\" SPATIAL_RES="1, 1" TYPE=GEOTIFF\
POLYGON_CROP_FILE="ne_10m_admin_0_countries.shp" POLYGON_CROP_USE_EACH=YES POLYGON_CROP_NAME_ATTR="<Feature Name>" POLYGON_CROP_FILENAME_SUFFIX="_crop.tiff"