Export images from layouts in ArcGIS for Desktop as JPEGs or PNGs, one per feature based on a unique field in a single layer. Single layer uniqueness supported, but may be used with multiple layers and data frames.
- Input layer contains the individual features to export images around. Features must be polygons or lines.
- Unique field is a text field within Input layer that contains unique values for each feature. These values will be used for output filenames.
- Output directory is the location where images will be stored.
- Fill type determines how each feature fills the data frame when exported. If set to
fill
, each feature will be scaled to use the largest width and height possible within the data frame, subject to the value of Extent scaling; output images will have the same dimensions but the data frame containing the features may vary in scale. Use theproportional
setting to calculate the smallest scale across all features, subject to Extent scaling, and apply that scale across all exported images. Default:fill
- Extent scaling is the percentage each extent is scaled within the data frame. A value of more than 100 scales up the dimensions of the extent, having the effect of reducing the feature size (smaller scale output). This is useful when padding within images is desirable, especially if line symbolization overflows the data frame and image when set to 100. Default:
100
- DPI is the standard dots per inch to use when exporting. Multiply DPI times the height and width of the page size to get the output image size, (e.g., 72DPI on a 16"x9" will produce an 1152x648 image). Default:
96
- Image type is one of
PNG
orJPEG
. Default:PNG
- JPEG quality is set between
0
and100
when Image type isJPEG
. Default:60
- Create a new map document.
- Set an appropriate page size, with the same aspect ratio that your final images will have. Whole numbers make for easy arithmetic.
- Add data to one or more data frames. Ensure the features you will export images based on are contained in the first data frame.
- As the tool only supports text features with unique names, if the desired field is numeric, add a text field and calculate strings into the new field.
- If the data includes separate features with the same name, dissolve into multipart features (or find another way to uniquely name things).
- Establish page layout.
- Run the tool, setting tool parameters as appropriate. Watch for extent scaling and fill type, in particular.
The arcpy.env.overwriteOutput
environment variable is honored.
The map document may contain multiple data frames, but the feature layer used for feature/image selection must be in the first data frame. Setup the page size and layout the data frame(s) as appropriate.
Demonstration map documents and sample data are provided in demo/
.
Minnesota's 87 counties are dissolved into multipart features and labeled with county name and FIPS code (parenthetically). Page size is set to 10"x10". Run the tool using the only layer provided—mn_county_boundaries_dissolved
— and CTY_NAME
as the unique field. This will produce 87 images, named by county, with dimensions ten times the provided DPI.
Interstate highways in Minnesota have been dissolved into multipart lines by route number. Use the InterstatesMN
layer and the ROUTE_NUMBER
field to generate ten images.
Demo two repeated, with an additional data frame at a fixed scale showing the entire state, with the variable frame to the right of the images.
- Minnesota Department of Natural Resources, County Boundaries, Minnesota
- Minnesota Department of Transportation, Roads, Minnesota, 2012
ArcGIS for Desktop 10.3.1. Other versions are untested. No extensions required.
- Only unique fields of type text are supported.
- Clipping the data frame to a shape produces errors which require restarting ArcGIS for Desktop.
- Filename uniqueness support is not fully functional. If
arcpy.env.overwriteOutput=True
, files may be overwritten. IfFalse
, warnings will be produced in the case of non-unique filenames (or, if files of the same name already exist). - All work and testing was done within the ArcGIS for Desktop Python console. Does it work outside of ArcGIS for Desktop? Maybe.