We do noxious weeds surveying, and have a geodatabase with separate point feature classes for each distinct species. In our Noxious Weed map, we have all of these species arranged into a single group in the table of contents.

Sometimes we make maps that need to display ALL the different species we've surveyed. We generally use proportional symbology based on our "WeedArea" field, but we often need to use the EXCLUDE function to only show those points that have attributes that match certain values.

It's a pain in the butt to set the symbology for each separate feature class individually, when we are using the same conditions for each one. An example exclude function we might use is SurveyDate >= date '2014-11-01 00:00:00' AND Control = 'UNTREATED'.

Is there any way to easily change the exclude condition of multiple feature classes all at once, to something like my example above? Likewise, if we are not using proportional symbology (and thus, also not using the EXCLUDE function) but instead displaying using the Categories -> "Unique values, many fields" option, is there any way to have the same conditional symbology be selected for all feature classes?

  • 1
    Does importing symbology from a .lyr file or another layer in the TOC maintain exclusion expressions? – Paul Oct 28 '15 at 20:43
  • Would importing the symbology from a layer you previously setup work for you? – ed.hank Oct 28 '15 at 20:43
  • @Paul haha you beat me to the punch!, and your second suggestion would probably work too (copying the layers and using different definition queries to display only certain data) as long as his queries dont change. – ed.hank Oct 28 '15 at 20:45
  • I tried importing from a .lyr file and it did not maintain exclusion expressions. Also, this wouldn't really speed things up since I would still have to go through this process for each and every feature class (which is 50+) which is what I'm trying to avoid. This is the sort of thing we have to change on a pretty frequent basis to display different time periods or types of data. – Tim Miller Oct 28 '15 at 21:35

This can be done with a little basic ArcPy and definition queries.

Throw all the layers you want to have the same definition query into a new ArcMap session. Then find/open the python shell. In the shell, copy/paste this, then press enter:

mxd = arcpy.mapping.MapDocument(r"CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    lyr.definitionQuery = "SurveyDate >= date '2014-11-01 00:00:00' AND Control = 'UNTREATED'"

Change your SQL (in the last line of code) as needed, and make sure you surround your SQL expression in double quotes. Once your layers have their definition query, you can drag them into your final map ArcMap session.

Here's a version that only updates layers in a given group layer:

groupLayer = "New Group Layer"
sql = "SurveyDate >= date '2014-11-01 00:00:00' AND Control = 'UNTREATED'"
mxd = arcpy.mapping.MapDocument ("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    if not lyr.isGroupLayer:
    if not lyr.name == groupLayer:
    for subLyr in lyr:
        subLyr.definitionQuery = sql

Update the variable groupLayer with the group layer name, and the variable sql with your where clause.

Note that the where clause is inclusive, not exclusive.

  • Would it be possible to simplify this (for the end user) and have it apply only to a particular Group Layer within the map, and avoid having to first open up all the feature classes in a new map and then drag them over? Or, alternatively, have it apply to all the feature classes within a particular geodatabase. – Tim Miller Oct 28 '15 at 21:54
  • I've updated my post with a version that works for all layers in a given group layer. – Emil Brundage Oct 28 '15 at 22:08
  • Thank you, it works great! HOWEVER, I went ahead and tried to turn this into a model for ease of use by my coworkers. I changed the "groupLayer" and "sql" values to arcpy.GetParameterAsText(0) and (1), respectively. I added matching parameters to the script's properties: one using the "Group Layer" data type, and the other using "SQL Expression" data type. It works, but when using the SQL Query Builder for the SQL statement, it doesn't populate with the available attribute table fields. Any thoughts on if there's a way I can fix this? – Tim Miller Oct 30 '15 at 17:55
  • I am guessing this is due to the fact that, technically, my only input is a Group Layer, which does not have any attributes by itself, and the Query Builder doesn't know to look at the layers contained within the Group Layer....Hopefully there's a way around this issue though. – Tim Miller Oct 30 '15 at 18:07
  • I'm glad it work for you @TimMiller. That being the case, I humbly request accepting the answer unless your lack of rep prevents it some how. As far as the SQL question, that's different than the issue here and should be its own question here on GIS Stackexchange. – Emil Brundage Oct 30 '15 at 19:53

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.