Skip to content

Export images of individual line or polygon features using arcpy

License

Notifications You must be signed in to change notification settings

wiringa/ArcPy-Feature-Image-Exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArcPy Feature Image Exporter

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.

Parameters/Usage

  • 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 the proportional 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 or JPEG. Default: PNG
  • JPEG quality is set between 0 and 100 when Image type is JPEG. Default: 60

General Process for Use

  1. Create a new map document.
  2. Set an appropriate page size, with the same aspect ratio that your final images will have. Whole numbers make for easy arithmetic.
  3. Add data to one or more data frames. Ensure the features you will export images based on are contained in the first data frame.
  4. 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.
  5. If the data includes separate features with the same name, dissolve into multipart features (or find another way to uniquely name things).
  6. Establish page layout.
  7. 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.

Map Document Setup

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.

Examples

Demonstration map documents and sample data are provided in demo/.

Demo 1: Minnesota counties

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.

Demo 2: Interstates in Minnesota

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 3: Multiple data frames

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.

Demo Data Sources

Compatibility

ArcGIS for Desktop 10.3.1. Other versions are untested. No extensions required.

Known Issues and Limitations

  • 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. If False, 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.

About

Export images of individual line or polygon features using arcpy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages