Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

I am attempting to use python and arcpy to automate the creation of some standardized maps I need to export for feature classes from various projects. I have a set of points and I need to export a single map for each point in the feature class, showing only one point at a time.

I can iterate through the features and export the maps just fine. However, the maps that come out are not panned to the right area, most of the time they are totally off.

I am using lyr.definitionQuery to hide all the features but one, then I need to pan my data frame so that it is centered on that feature, then export the map, and repeat for all the features in the feature class. The best I could find to recenter the data frame was the df.panToExtent function. Which works fine when I run it from the python window in ArcMap but doesn't seem to keep up when it runs inside the loop. Any help is MUCH appreciated!

Here is my loop:

while isoPosition < isoCount: #iterate through the feature class
    query = "[Type] = 'Isolate' AND " + "[FieldID] = " + "'" + FieldIDs[isoPosition] + "'"

    #center on feature

    #Refresh the view to load new image tiles

    #Set the layers definition query equal the query text
    lyr.definitionQuery = query

    #String for a unique file name for each map, corresponding to the current Field ID in FieldIDs
    filename = FieldIDs[isoPosition]

    #Export the map document:

    #Move forward in the FieldIDs array, so that next time through we export the next map
    isoPosition += 1
share|improve this question
up vote 1 down vote accepted

I have solved my own problem. It seems that I just had the order of the commands messed up. I needed to set the layer definition query BEFORE using panToExtent function, not after.

share|improve this answer

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.