I am currently building a script to zoom to each providence within a country and export the providence and major cities (I have a layer for each) as a map package.
I need it to select the record, zoom to selected record, run a definition query, and export the result as a map package with labels as annotations, and repeat for each value within the preselected field.
This is what I have so far:
import arcpy, os arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd) layerName = arcpy.GetParameterAsText(0) fieldName = arcpy.GetParameterAsText(1) imgLocation = arcpy.GetParameterAsText(2) whereList =  layerFile = arcpy.mapping.Layer(layerName) layerFile.definitionQuery = "" print df.name with arcpy.da.SearchCursor(layerName, fieldName) as cursor: for row in cursor: for item in row: whereList.append(item) for wl in whereList: layerFile.definitionQuery = fieldName + "= '" + wl + "'" outFile = imgLocation + "\\" + wl + ".png" arcpy.RefreshActiveView() arcpy.mapping.ExportToPNG(mxd, outFile, df, resolution=300) del mxd
Currently the script does export a .png image, however it does not zoom to each selected record. I need some tips for fixing this as well as exporting out each individual result as a map package with annotative labels.