0

I'm using ArcPy for some automation and I need to update the layer definition query multiple times while running the same script.

I've only been able to find ways to update the layer definition query when loading layers. I understand there's a way to use arcpy.mapping.ListLayers() but I can't figure out how from documentation.

The ArcGIS documentation I've been able to find only shows how to update the layer definition query through the UI, not through ArcPy.

For context on my code: I have a csv of pressure readings joined to a shapefile of sensor locations from which I am using IDW interpolation to generate rasters. There is a full year of daily pressure readings and I am using layer definition queries to get the reading from each day at each sensor, so I have one IDW raster per day.

Using ArcGIS Desktop 10.6, running Windows 10 x64.

closed as off-topic by PolyGeo Jul 22 at 19:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

3

Layers have a definitionQuery property.

Example:

lyr = arcpy.ListLayers (mxd, "MyLayer") [0]
lyr.definitionQuery = "State = 'California'"

Not the answer you're looking for? Browse other questions tagged or ask your own question.