1

I've read a lot about the topic data driven pages. I'm writing a python script for ArcGIS and I've defined my stripmap using the arcpy.StripMapIndexFeatures_cartography command and now I have to set up Data Driven Pages with all the parameters it needs. My only problem is that I cannot understand how to do this. Is there a specific command in the arcpy library or a specific workaround to do this?

3

If you have not already gone through the ESRI arcpy.mapping tutorials and ArcGIS Resources pages, they have heaps of sample scripts to comb through. I would suggest looking at these first:

Tutorials:

If you are using 10.0, you can find similar help topics for it on the 10.0 help site.

  • Hi Ryan, and thanks for answering.. my exact problem is that the tutorial itself says: "Data Driven Pages must first be enabled and authored within a map document (.mxd) using the Data Driven Pages toolbar in ArcMap before it can be referenced with arcpy.mapping." – Annalisa Minelli Oct 7 '12 at 14:43
  • well.. now I'm trying to write a script to automatize everything - but I cannot - from how it seems. And maybe now I will be forced to stop my script at a certain point and say the user: "please, open the ddp setup and set this parameter in this way - this other in this way.." which is near horrible to me. But it seems there's no other way if I can't ENABLE data driven pages from arcpy, or arcpy.mapping.. or wahtever it is :( – Annalisa Minelli Oct 7 '12 at 14:46
  • Hi! Do you have any update or solution on this issue? Is there a way to automate everything, including "enabled and authored within a map document (.mxd) using the Data Driven Pages toolbar in ArcMap" you mentioned? Thanks! – Energetic Codfish Mar 18 at 14:42
1

You can largely avoid opening the reference mxd by using layers. This is generally how arcpy.mapping operates anyways, is through layer files.

For example, I have used a workflow which looks something like this:

  • arcpy.MakeFeatureLayer_management - here is where you can subset the data
  • arcpy.SaveToLayerFile_management
  • arcpy.mapping.UpdateLayer - allows you to switch out an existing layer in the mxd with the one you have created for your needs
  • arcpy.mapping.DataDrivenPages.refresh()

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.