Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know of a way to batch convert shapefiles to jpegs or another common image format?

edit: I should have clarified that I would like to apply a styling to each shapefile, and then export the shapefile with that styling to an image.

For example, I have census tracts in a county, and I want an image of each individual tract highlighted while the other tracts are all the same color.

share|improve this question
Do you have any particular software in mind? An application that you use regularly? Or do you just any way possible? – RyanDalton Jun 3 '13 at 20:47
I use Arc and Q pretty regularly and am getting more familiar with arcpy, but am really just looking for any way to do this, even another third party software package – camdenl Jun 3 '13 at 21:49
So for clarification, you are basically just looking to generate thumbnails (or larger) of the shapefile, no styling, no colors, no labels, etc right? – RyanDalton Jun 3 '13 at 22:21
I started thinking about this last night, and I see that my original question might be misleading. I would like to apply a styling and then export the map over 100+ times for each indiviual shapefile with the applied styling. – camdenl Jun 4 '13 at 13:19
up vote 12 down vote accepted

There are many free tools like:

But in Python, the reference is Mapnik and Getting Started In Python

  • You create a map (width and height in pixels, background color, etc)
  • You create Styles which determines how the data is rendered
  • You add a datasource (shapefile, etc.) and create a layer from it.
  • You render the map
  • the same map and styles parameters can be applied to multiple files (via an XML file)

see the examples in Mapniks Maps

Simple Rendered images from TM_WORLD_BORDERS-0.3.shp

enter image description here

selection of a country (Angola) in the shapefile:

enter image description here

Another example from Mapniks Maps

enter image description here

share|improve this answer

You could add all of the layers to a mxd, then loop through them and run

arcpy.mapping.ExportToJPEG(map_document, out_jpeg, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {jpeg_quality}, {progressive})

for each layer in the map.

share|improve this answer
Just to add to this solution, you could use arcpy.da.walk to generate an initial list of input data:… – scw Jun 4 '13 at 8:00

This similar question has answers that use FME to convert DWG to JPG. The process will be similar for converting shapefiles.

This example has example workspaces you can download.

FME is well suited to handling batch processes. For example, you can point the reader to a folder and it will include all shapefiles in the folder.

I created a simple workflow which reads all the shapefiles in a folder and writes them out to separate JPGs.


share|improve this answer

Oh, I did this yesterday with counties in Montana! Is it too late to answer? Assuming you've already used Split to make a shapefile for each census tract, I found that it was easy (lazy) to handle them in a Group Layer. Assuming that's the only Group Layer in your document, don't be shy about opening up the ArcPy window and entering:

# Setup, defining a variable for the map document, the data frame,
# and a list of layers:
mxd = arcpy.mapping.MapDocument("Current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layers = arcpy.mapping.ListLayers(mxd)

# To copy symbology to all subLayers in the group layer,
# using a template, any normal polygon shapefile will do:
# (datum conflict warnings are irrelevant)
for layer in layers:
  if layer.isGroupLayer:
    for subLayer in layer:
      arcpy.ApplySymbologyFromLayer_management(subLayer, "templatelayer")

# Export one map with each county/tract highlighted, toggling visibility
# of each sublayer before and after:
for layer in layers:
  if layer.isGroupLayer:
    for subLayer in layer:
      print "Exporting " + str(
      subLayer.visible = True
      slfile = "C:\\YourPathHere\\Subdir\\Etc\\" + str( +
      arcpy.mapping.ExportToPNG(mxd, slfile, df, df_export_width=640,
df_export_height=480, transparent_color="255, 255, 255")
      subLayer.visible = False

Export to jpg is similar, but jpgs are kinda yucky. This was my first ArcPy experience, so I'm sure there are more elegant ways to do this.

share|improve this answer
You did do the exact same thing eh? Glad you figured it out, thanks for the response – camdenl Jun 25 '13 at 1:37

Instead, just load the shp file into ArcMaps and configure it how you like. Then use either Alt + Print Screen or the Snipping Tool to get a screenshot. Then you will have a jpg or png that looks exactly like how the shape file was rendered.

share|improve this answer
I don't think that addresses the key component of the question which is how to automate the process. – RyanDalton Nov 25 '13 at 19:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.