Monday, 8 January 2018

arcgis desktop - Applying Different Label to Data Driven Pages Current Target?


I'm exporting the pages to png files. The pages are divided by lots. Each page has a label with the lot number.


In the case of the sample included, 18-385 is the lot being exported. Pieces of several other neighboring lots are also printed.


What I would like to do if possible is format the label of the lot being exported different from the neighboring lots.


The first picture is what I have so far, and the second picture is what I would like to do.



  • I am very new to ArcGIS.

  • I'm doing the exports in the Geoprocessing->Python box. I don't know yet how to get to a full IDE where I can save code.


  • I'm using ArcGIS 10.1


If it helps, here's the code I'm using.


mxd = arcpy.mapping.MapDocument("CURRENT")
ddp = mxd.dataDrivenPages
basePath = "C:\\Downloads\\Dev\\ArcGIS\\Fulton\\"
for pageNum in ddp.selectedPages:
mxd.dataDrivenPages.currentPageID = pageNum
distNum = mxd.dataDrivenPages.pageRow.DistNum
savePath = basePath + distNum

fileName = savePath + "\\" + mxd.dataDrivenPages.pageRow.DistPage + ".png"
print fileName
if not arcpy.os.path.exists(savePath):
arcpy.CreateFolder_management(baseDir,dirName)
arcpy.mapping.ExportToPNG(mxd, fileName,resolution=300)
del mxd

What I have: What I have


What I want: What I want



Answer




There isn't a really an elegant way to do this, as far as I know. However, I've recently successfully accomplished something similar using multiple copies of the layer and using Page Definitions.


Here's the basic idea, and you can modify it to suit your needs:


The layer which defines your Data Driven Pages should show the symbology but no labels. Then, you can have two separate copies of the layer which would have no symbology. One of them will label the lot you want and the other will label the surrounding lots. In order to define which ones get labeled, go to Layer Properties, and on the Definition Query tab, select Page Definition:


enter image description here


Then, on the layer that will label the surrounding lots, set it to show features that don't match the page name. You'll have something that looks like this:


enter image description here


Similarly, for the lot you want to label in red, you'll have something like this:


enter image description here


There are other variations you can do as well, such as running your Data Driven Pages from a layer that is actually turned off. Then, you can set the symbology of the lot you want to focus on to be a thicker outline, or a different colour to help it stand out.


Note, this should all be set in your MXD. Then your code should work the same.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...