AcrPy select current feature in data driven page to highlight feature on map

1298
6
Jump to solution
06-06-2011 12:30 PM
Dr__EleeDumas
New Contributor
I am using data driven pages to generate a map book of 507 utility districts in our county.  I want to select the current feature on the map page so that it is highlighted in the exported .pdf.  With the .mxd open, the base python code I am using is:

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
# Select current feature ?

   print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
  arcpy.mapping.ExportToPDF(mxd, r"D:\PCMElee\Utilities\RouteBooks\MapBook_PCU_RouteBooks\RouteBook_Page" + str(pageNum) + ".pdf")

I have looked at a number of posts and the help. So far I not found a way to approach the problem with ArcInfo 10.0

Thank you in advance for your help and direction on this.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
StevenDrake
New Contributor II
I am using data driven pages to generate a map book of 507 utility districts in our county.  I want to select the current feature on the map page so that it is highlighted in the exported .pdf.  With the .mxd open, the base python code I am using is:

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
# Select current feature ?

   print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
  arcpy.mapping.ExportToPDF(mxd, r"D:\PCMElee\Utilities\RouteBooks\MapBook_PCU_RouteBooks\RouteBook_Page" + str(pageNum) + ".pdf")

I have looked at a number of posts and the help. So far I not found a way to approach the problem with ArcInfo 10.0

Thank you in advance for your help and direction on this.


Elee,

I think I figured out a way to do what you are asking but without the scripting. If I understand correctly, you want only certain features to show on each page. So if you have a page with two or more utility areas visible, you only want to show only the features of the utility area focused on by the page, and ignore  features in the other utility areas.

Here's how to accomplish this... bring up the "Data Frame Properties" of the data frame. Select the "Data Frame" tab. In the "Clip Options" section, select "Clip to current data driven page extent" in the top left dropdown. In the "Exclude Layers..." area, check all layers you want drawn beyond your utility area.

In the "Border" dropdown, set the border to whatever line color and width you would like the utility boundary to appear. Set the fill and outline of your utility layer to transparent. These latter two steps will draw a line along the boundary consistantly, otherwise you will have to widen the layer lines and/or offset the lines negatively.

Steven

View solution in original post

0 Kudos
6 Replies
KimOllivier
Occasional Contributor III
You are not very explicity on what the selected feature is. I assume you mean the page in an index layer in a location map inset?

In the index dataframe copy the layer that is being used for data driven pages.
The first layer will be an outline say Index.
The second layer (renamed say Sheet) will be the highlighted tile. Set this layer to be a filled colour.

With data driven pages enabled, open the properties>definition and you will see two button options instead of one, Query Builder or Page Definition. Select the page definition button and choose your options. Set the pages field and set Features that Match.

If it is not the index that you want highlighted, the process is the same with any other feature layer, add a field so that the feature(s) to be highlighted has the pagename that corresponds in the attributes.
0 Kudos
Dr__EleeDumas
New Contributor
Kimo;

Thank you so very much for your quick reply.  It does exactly what I need and is a very simple and elegant solution.  As i write this i am producing the output i need.

Elee
0 Kudos
JerryHughes
New Contributor
Kimo,
I do not get the two options 'Query Builder or Page Definition' as you note below.  My data driven pages is fine.  I am using an attribute in a layer called 'Sites' to drive the pages.  When I go to Sites/properties/definition query/ I only get the 'Query Builder'.  Am I not understanding the steps below?
jerry






You are not very explicity on what the selected feature is. I assume you mean the page in an index layer in a location map inset?

In the index dataframe copy the layer that is being used for data driven pages.
The first layer will be an outline say Index.
The second layer (renamed say Sheet) will be the highlighted tile. Set this layer to be a filled colour.

With data driven pages enabled, open the properties>definition and you will see two button options instead of one, Query Builder or Page Definition. Select the page definition button and choose your options. Set the pages field and set Features that Match.

If it is not the index that you want highlighted, the process is the same with any other feature layer, add a field so that the feature(s) to be highlighted has the pagename that corresponds in the attributes.
0 Kudos
KimOllivier
Occasional Contributor III
You don't get the chance to set a [Page Definition] on the DDP index layer. You have to make a copy of the layer and set the second layer to have a dependency on the index layer. The second layer is the one that you change to fill.

Note that there is an Extent tab on the DDP menu where you set the zoom percent for the first index layer.

I don't know how I managed to get two layers to have dual buttons! I still have it, but cannot reproduce it in a new MXD.
0 Kudos
StevenDrake
New Contributor II
I am using data driven pages to generate a map book of 507 utility districts in our county.  I want to select the current feature on the map page so that it is highlighted in the exported .pdf.  With the .mxd open, the base python code I am using is:

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
# Select current feature ?

   print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
  arcpy.mapping.ExportToPDF(mxd, r"D:\PCMElee\Utilities\RouteBooks\MapBook_PCU_RouteBooks\RouteBook_Page" + str(pageNum) + ".pdf")

I have looked at a number of posts and the help. So far I not found a way to approach the problem with ArcInfo 10.0

Thank you in advance for your help and direction on this.


Elee,

I think I figured out a way to do what you are asking but without the scripting. If I understand correctly, you want only certain features to show on each page. So if you have a page with two or more utility areas visible, you only want to show only the features of the utility area focused on by the page, and ignore  features in the other utility areas.

Here's how to accomplish this... bring up the "Data Frame Properties" of the data frame. Select the "Data Frame" tab. In the "Clip Options" section, select "Clip to current data driven page extent" in the top left dropdown. In the "Exclude Layers..." area, check all layers you want drawn beyond your utility area.

In the "Border" dropdown, set the border to whatever line color and width you would like the utility boundary to appear. Set the fill and outline of your utility layer to transparent. These latter two steps will draw a line along the boundary consistantly, otherwise you will have to widen the layer lines and/or offset the lines negatively.

Steven
0 Kudos
JessicaKirby
New Contributor III
Thanks Steve for this detail explanation of this functionality!  It was exactly what I needed today!! Worked like a charm!
0 Kudos