2

I have a layer named 'Landuse' in TOC. Symbology type is 'Unique value" for the field 'Landuse', for example:

  • Residential
  • Commercial
  • Public
  • Recreational
  • Etc.

Is there any way to automatically remove Commercial (for example) since actually there is no 'Commercial' polygon in 'Landuse' layer by existing tool or by Arcpy coding?

Because there are many unique values in the 'Landuse' layer, and I have to do it many times, so that I dont want to do it manually.

2
  • I am guessing your symbology is driven off a subtype field that has all of these types? If you click on the count column on the right of the symbology tab in the layer properties dialog you will see the count for each type. Control + click all the 0 counts, rtClick remove. Are you looking for a programmatic solution? Commented Jun 8, 2016 at 2:52
  • I know to do it manually. Yes, I mean to ask for programmatic solution in Arcpy, if possible. Commented Jun 13, 2016 at 16:06

2 Answers 2

1

Try this (untested) snippet on a layer.

if lyr.symbologyType = 'UNIQUE_VALUES':
    field = lyr.symbology.valueField
    freqTable = arcpy.Frequency_analysis(lyr.dataSource,"tempTable", field) 
    freq = arcpy.da.TableToNumPyArray(freqTable ,field).tolist()
    vals= [val[0] for val in freq]
    lyr.symbology.classValues = vals
0
0

Select Landuse layer.
Right click and select properties.
Select the tab Symbology.
Select Categories, then Unique values.
Then with the drop down option for value field select for "Unique value."

This should then list all your zoning types below in the box. Here you can then right-click on Commercial and select remove value(s). This should remove Commercial from the list of values shown in legend or toc.

1
  • 1
    Sorry, I have asked the wrong question. I mean to ask: HOW CAN I AUTOMATICALLY REMOVE UNIQUE VALUES WITH NO OBJECT (Count = 0) IN EXISTED SYMBOLOGY? Commented Jun 13, 2016 at 16:08

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