I want to implement a script that runs through each feature of a feature class, zooms to the extent of the feature, sets the scale to 1:5.000 and adjacent takes a picture of the scene. The steps are in general very easy. My idea is to use the following code lines:

import arcpy.mapping
myMXD = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(myMXD)[0]
layer = arcpy.mapping.ListLayers(myMXD, "", df)

# Zoom and Scale
df.scale = 5000

My Question is: How can I run through the whole list of features so that the script will zoom on each feature, set the scale back to 1:5000 and takes a picture? My first idea was to use the Search Cursor to run through the attribute table, but how can I than declare that the feature that is actually "visited" by the cursour is the selected one?

Thanks for any help and suggestions.


  • 4
    You may want to look into Data Driven Pages. You can include Data Driven Pages in your Python script and give a static scale (like 5000) as you go to each feature. It can export each zoomed to feature as a separate image. The limitation is that Data Driven Pages only exports as a pdf file. You need ArcGIS 10 to use Data Driven Pages.
    – Baltok
    Feb 4, 2013 at 22:16
  • The problem is that I have in real several DFs in my document and my collegue told me, that it is not possible to use Daten Driven Pages on several DFs. So my solution would be to implement an own python script...
    – Sven
    Feb 4, 2013 at 22:20
  • It's true that Data Driven Pages can only be applied to one Data Frame at a time. So, you want your Python script to use SearchCursor to iterate through features and update on multiple Data Frames at the same time?
    – Baltok
    Feb 4, 2013 at 22:31
  • That would be the preferred solution.
    – Sven
    Feb 5, 2013 at 8:09

1 Answer 1


I would use a two step process:

  1. Create a Python list of every unique ID by running a SearchCursor through it (preferably arcpy.da.SearchCursor but this requires ArcGIS for Desktop 10.1 or higher)

  2. Iterate through that list to use the ID to make and use a SQL expression that lets you Select By Attribute (and zoom to) or apply a Definition Query (and zoom to) to each in succession - I suspect the Definition Query method will provide significantly better performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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