Programming ArcGIS Pro with Python (2nd Edition) by Pimpler Eric

Programming ArcGIS Pro with Python (2nd Edition) by Pimpler Eric

Author:Pimpler, Eric [Pimpler, Eric]
Language: eng
Format: epub
Publisher: Technics Publications
Published: 2021-04-29T16:00:00+00:00


Set the fields property on the UniqueValuesRenderer to the Condition field and apply the symbology to the layer.

import arcpy.mp as map

try:

aprx = map.ArcGISProject(“CURRENT”)

for m in aprx.listMaps(“Streets and Railroads”):

for lyr in m.listLayers(“Street_Centerlines”):

if lyr.isFeatureLayer:

sym = lyr.symbology

sym.updateRenderer(‘UniqueValueRenderer’)

sym.renderer.fields = [“Condition”]

lyr.symbology = sym

except Exception as e:

print(“Error: “ + e.args[0])

You can check your code against a solution file found at c:\Student\ProgrammingPro\Solutions\Scripts\UniqueValueRenderer.py

Load the code into the ArcGIS Pro Python window and run it. The Street_Centerlines layer will be updated as seen in the screenshot below.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.