2

I need to find a way to reclassify/refresh graduated color symbology in between exporting data driven pages.

Background: I have spatially joined Block Groups (BGs) to 1000 facilities (and facility ID) within 10 miles. There are multiple instances of the same BGs because they are located in close proximity to multiple facilities.

I prefer to use the standard deviation classification method. Currently, when Data Driven Pages are enabled and I classify the data - the value ranges are applied are relevant to what is displayed (this is good). The problem arises when I toggle to the next page and this is not re-calculated, but rather continues to use the value ranges for the previously displayed BGs.I cannot display all at once, because the multiple occurrences overlap. Also, for one particular facility a BG might represent a lower value while for another the same BG might represent a larger value.

I export data driven pages in very basic python script. One answer would be to insert code that applies symbology from a different layer before exporting the page. This process works manually in Arcmap: Apply Symbology > refresh > export page...etc. I have limited experience with python, and the 2nd to last line I have added below isn't making it happen (but works in a separate script).

This is the python I am currently working with:

import arcpy
mxd = arcpy.mapping.MapDocument(r"E:\Templates_MXD\BU_5Mile.mxd")
export_path = r"C:\Users\sder\Desktop\Test\\"
field_name = "ID"
df = arcpy.mapping.ListDataFrames(mxd, "Business Analyst Map")[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "BKtoBG", df)[0]
sourceLayer = arcpy.mapping.Layer(r"E:\Templates_Layer\BKtoBG.lyr")

for i in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = i
    row = mxd.dataDrivenPages.pageRow
    print row.getValue(field_name)
    arcpy.mapping.ExportToPDF(mxd, export_path + row.getValue(field_name) + ".pdf", resolution=200, image_quality="BETTER")
    arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer,True)
del mxd
  • I think we need you to describe your steps much more precisely and to focus your question on where what you observe starts to deviate from what you expect. – PolyGeo Oct 11 '16 at 21:32
  • I feel that I have revised my question to be more clear. Please let me know if I have not yet met expectations. – SDerz Oct 12 '16 at 19:22
  • I'll re-open for now but I suspect you may need to post some code before you are likely to attract potential answerers. – PolyGeo Oct 12 '16 at 19:44
  • 1
    That's tricky. Arcpy hasn't really been built out to include a lot about how data is displayed. It's awesome for geoprocessing, but not so much the cartographic stuff. You can import symbology from a pre-existing layer file. See this article: support.esri.com/technical-article/000012251 Alternatively, if you're handy with ArcObjects but you really want to use python for this, you can hit ArcObjects from within your python script. There's a good discussion on python vs. ArcObjects for symbology here: geonet.esri.com/thread/40656 – geobug Oct 18 '16 at 4:47
  • I agree. If you find a workable solution, I'd love to hear about it. – geobug Oct 18 '16 at 21:05
1

I was able to get this to work with the original python in part by using Geobug's reccomendation on arcpy.mapping.UpdateLayer followed by inserting:

updateLayer.symbology.reclassify()

&

arcpy.RefreshActiveView()

I haven't yet gone back to test which of these components is actually doing the trick, but collectively it works. There is a chance the reclassifying function alone would have done the trick but there is very little documentation available explaining this. Thanks for the help, I am very pleased to have found a way around this.

| improve this answer | |

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.