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.

| improve this question | | | | |
3

Layers have a definitionQuery property.

Example:

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

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