Hello Community,
I recently upgraded ArcGIS Pro to 3.4.2, which included Python 2.4.0 and the new Map() module. I am working on updating one of my scripts and have run into a road block I was hoping someone could help me with.
My map has several grouped layers whose definition expressions are updated by python script. My usual method of defining each layer by title doesn't work anymore with the new mapping module. Does anyone know how I can point to my layers in Python 2.4's new module?
Here is a sample of my previous method:
import arcgis
from arcgis.map import Map
from arcgis.gis import GIS
gis = GIS("home")
# New method to grab web map in Python 2.4
wm_item = gis.content.get("<item id>")
webmap = Map(item=wm_item)
# report update date
reportDTSQL = '02012025'
# (Old, not-working method of updating layer expression-- NEEDS UPDATING)
# get layers of interest
enrolledLyr = webmap.get_layer(title="Locations Enrolled Only")
# apply new filter expression to each layer's json
enrolledLyr["layerDefinition"]["definitionExpression"] = f"(category = 'Active') AND ({reportDTSQL})"
# Update web map object with new json
webmap.update_layer(dict(EnrolledLyr))
Thank you for any help!