AnsweredAssumed Answered

python script: zoom to each county in a state shp and export a pdf map

Question asked by bahanson on Jul 31, 2013
Latest reply on Aug 1, 2013 by dan_h_b
I would like to create a python script that will zoom into each county in a state shapefile and export a pdf map. I have found two DataFrame methods, panToExtent and zoomToSelectedFeatures. I don't want to use panToExtent because I want it to zoom to the shape of the county. My code uses the zoomToSelectedFeatures but i'm not exactly sure how to select features
. This is what my code looks like so far. Thanks for the help!

import arcpy  mxd = "C:/ArcPyTests/Untitled.mxd" mapdoc = arcpy.mapping.MapDocument(mxd) counties = "C:/ArcPyTests/countyPopulation.shp" rows = arcpy.SearchCursor(counties) output = "C:/ArcPyTests/" df = arcpy.mapping.ListDataFrames(mapdoc)   for row in rows:     mapdoc.extent = row.Shape.extent     df.zoomToSelectedFeatures(mapdoc.extent)     outputname = row.County     arcpy.mapping.ExportToPDF (mapdoc, outputname + ".PDF")     print "Output " + outputname + " complete"      del mapdoc

Outcomes