2

(ArcMap 10.6.1)

I have a map that is using DDP to index through and show ~1800 short line features (bridges), and I need the map to be pretty zoomed in because I'm wanting to show the immediate context (especially local road names) of where the bridge is. While this is easy enough to do, in this application, I think it is important to give the broader context of the location. These bridges cover a 21 county area, and I want to have an inset map that shows the current county with an extent indicator that shows where in the county the current extent is showing. I realize that I could do this by having a separate map document for each county, but that feels like it would kind of defeat the purpose of DDP. 

From what I've found researching this issue, it isn't possible to have multiple indexes, which is what I would want. Is there a way in python to make the inset map "zoom to feature" based on the county name that is listed for the current feature in the index?

  • 1
    In your second data frame you can go to its Properties and on the Data Frame tab there is an Extent dropdown which can be set to "Other Data Frame". That might be good enough for you. There is also a two DDP solution in which one project creates the insert maps and exports them to tifs, and then the main project uses the tifs to fill an inserted image box based on the path value in the index layer for each map. Here's an old link still working today for that: resources.arcgis.com/en/help/main/10.1/index.html#//… – johns Aug 5 at 16:40
3

Heavy handed solution, no scripting:

  • Spatial join of counties one to many to your culvert lines, i.e.pages will result in 1800 polygons, each having page name.
  • Add polygons to reference dataframe and apply DDP definition query (match) on this layer. I called it MANY_POLYGONS.
  • Use properties of reference dataframe as follows:

enter image description here

Works like a charm.

  • Wow, this works perfectly, THANK YOU! – Zeke Hall Aug 7 at 13:59
1

Never tried it before, but I guess it should be feasible this way:

  1. Get the index layer's row object for the active or current page with pageRow property of DataDrivenPages object
  2. Get the county name in the row (see here to understand what is a row and how to use it)
  3. Select the county in the couty layer using the extracted couty name from the index layer's row
  4. Use the zoomToSelectedFeatures() method of the DataFrame object to zoom the inset Data Frame to the desired county extent

EDIT

Expanding a bit on step 3 to hopefully clarify the point.

The key here would be to make a selection on the county layer (and by layer I do mean layer), to then zoom the inset Data Frame to the selection (by means of the DataFrame's zoomToSelectedFeatures() method (step 4).

So, retrieve the county layer by means of arcpy.mapping.ListLayers like:

import arcpy
mxd = arcpy.mapping.MapDocument("YOUR_MXD_HERE.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "inset_dataframe_name")[0]
countyLayer = arcpy.mapping.ListLayers(mxd, "countylayername", df)[0]

Now, countyLayer is a Layer object. I don't know if you can pass it directly to arcpy.SelectLayerByAttribute_management(countyLayer, "NEW_SELECTION", " [NAME] = ' + YOUR_COUNTY_NAME_RETRIEVED_IN_STEP_2 + ' ") or if you need to explicitly pass its dataSource (property of the Layer object) to select it, like:

arcpy.SelectLayerByAttribute_management(countyLayer.dataSource, "NEW_SELECTION", " [NAME] = ' + YOUR_COUNTY_NAME_RETRIEVED_IN_STEP_2 + ' ")

Either way you should be able to perform a selection on the desired county layer according to the current county name found in the current index layer of your Data Driven Page (step 1 and 2).

Probably not an easy task, but this should give you more than an idea to hopefully do what you want. Good luck!

  • I'm still a little new to arcpy, and I'm having trouble figuring out step 3. I've gotten the name of county out of the index layer, but how do I use that to select the feature in another layer that had that name name? – Zeke Hall Aug 6 at 13:31
  • Check the example at the end of the arcpy.SelectLayerByAttribute_management page. You'll need to feed the county name in the where_clause parameter. Something like arcpy.SelectLayerByAttribute_management("countylyr", "NEW_SELECTION", " [NAME] = ' + YOUR_COUNTY_NAME_HERE + ' ") – umbe1987 Aug 6 at 14:04
  • I've been scouring the documentation, and from what I can tell, you can't work with the data behind a layer within a map document. The terminology here is really important which is tripping me up some and my brain hurts. Can you break step 3 down in more detail for me, taking care to use the correct terminology for the different objects and functions involved? – Zeke Hall Aug 6 at 15:59
  • @ZekeHall I edited my answer to give you some details on step 3. Beside that, you really should study GIS terminology in advance and know how Python works. Good luck ;) – umbe1987 Aug 6 at 18:24
  • Thank you so much for your help on this and for elaborating where I was having trouble understanding! @FelixIP's solution worked perfectly, but I will refer back to your instructions when I have time to help me learn more about scripting. Thank you! – Zeke Hall Aug 7 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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