Constant extent with Data Driven Pages

9595
12
03-14-2011 01:41 PM
by Anonymous User
Not applicable
Original User: zorbac

Wondering if there is a way to make the extent remain the same, even if the index layer extent varies. I'd like to do an atlas with one page for each bus route that intersects a study area. So, the index layer is based on the bus routes (each feature is equal to the envelope defined by a given route) For each page of the atlas I want the extent to remain unchanged (showing entire study area). Then I can use the "page definition query" settings to query the bus routes layer such that the corresponding bus route is shown on the map.

One solution is to create an index grid with a bunch of stacked polygons each equal to the same extent and populate an attribute with the route numbers. If I have to I'll do this, but I thought I would check if there is a better way. I believe this would be a nice enhancement. You could easily do atlases that compare multiple themes of data for the same area or temporal maps of the same area, etc...
0 Kudos
12 Replies
GerryGabrisch
Occasional Contributor III
A series of map at the same extent each showing a different feature in a feature class?
Here is some code that will produce a new map for each water sample sites. Each output map is the same extent and only one sample site appears on each output map.  Each output map has the title changed based on an attribute and each output map is named after the attribute as well.  It would be easy to code this for pdf.

The (ham-fisted) code would require some changes...a valid path to your mxd, "WaterSampleSiteMaster" (line 10) is the feature layer in my mxd and SiteID (line 13 and elsewhere) is an attribute in the Water sample site feature class that is used to label the map outputs and the map title.

Good Luck. 


try:
    import arcpy, sys, traceback
    print "Working..."
    
    mxdPath = r"Z:\GISpublic\GerryG\WaterResources\WaterSampleSiteAutoMap\WaterSampleSiteAutoMap22.mxd"
    
    mxd = arcpy.mapping.MapDocument(mxdPath)
    df = arcpy.mapping.ListDataFrames(mxd)[0]
    
    lyr = arcpy.mapping.ListLayers(mxd, "WaterSampleSiteMaster", df)[0]
    print lyr.dataSource
    theAttribute = "SiteID"
    #GetAListOfEachAttribute
    listOfAttributes = []
    print "Start cursor"
    rows = arcpy.SearchCursor(lyr.dataSource)
    for row in rows:
        listOfAttributes.append(row.getValue(theAttribute))
    for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
        if elm.name == 'gbglabeler':
            elm = elm
            break
    for item in listOfAttributes:
        GBGquery = '"SiteID" =' + '\''+ item + '\''
        print  "Working on: ",item
        print GBGquery
        lyr.definitionQuery = GBGquery
        elm.text = "Site: " + item
        
        outputjpg = "Z:\GISpublic\GerryG\WaterResources\WaterSampleSiteAutoMap\SiteMaps\\" + item + ".jpg"
        arcpy.RefreshActiveView()
        arcpy.mapping.ExportToJPEG (mxd, outputjpg)
    print "done"
except arcpy.ExecuteError: 
    msgs = arcpy.GetMessages(2) 
    arcpy.AddError(msgs)  
#If the error is with the script, or with python, find error and report it to the screen...
except:
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
    msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)
ChrisHills
Occasional Contributor

I too would like to be able to maintain the same extent for DDP. All that is needed is to add an additional option on the "Extent" tab which says "Keep current extent".

0 Kudos
MatissValdmanis1
New Contributor III

I found a simple way to achieve DDP where the extent of the maps remains exactly the same:

  1. Find the centroid of the extent you want (e.g. find the centroid x and y field values using Calculate Geometry on a polygon you want to centre your DDP maps on) and put a point there
  2. Run Feature to Point on the polygons you want to base your DDP attributes on* (only works with ArcGIS Advanced Licences. You can work around this step, see below)
  3. Edit the points and move and snap them to your original polygon's centroid location
  4. Set your mxd's extent to the one you want (centered on the point from Step 1)
  5. Run the DDP tool but have the F2P Point fc as the DDP Layer.
  6. Set your DDP tool Extent tab to Center and Maintain Current Scale

*If you don't have an ArcGIS Advanced Licence:

  1. In your DDP polygons: in the attribute table, add X and Y fields and calculate the x and y centroid field values using Calculate Geometry
  2. Export the attribute table to CSV
  3. Add X/Y points from the CSV table
  4. Convert X/Y Points to an Geodatabase FC
  5. Edit the X/Y Point fc and snap them to the DDP centroid point