Hi everyone
For disclosure, i asked this question in python - How to remove a specific unique value with arcpy - Geographic Information Systems Stack Exc... but didn't get useful answers.
using arcpy, i would like to remove from 50 mxd files, a specific unique value called "residence a" (exist in 3 layers) from the table of content.
The value of "residence a" is the number "70" in the attribute table (in field named "YEUD")
When i use this code:
import arcpy,os,sys
from arcpy import env
env.workspace = r"C:\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname)
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "*")[0]
if lyr.symbologyType == "UNIQUE_VALUES":
vals = lyr.symbology.classLabels
for v in vals:
if v == "residence a":
print mxdname
print lyr.name
print ("1 in layer " + lyr.name)
arcpy.mapping.RemoveLayer(df, v)
mxd.save()
del mxd
i get en error:
>>> Project -.mxd mig1 1 in layer mig1 Traceback (most recent call last): File "C:/Users/yaron.KAYAMOT/Desktop/remove UNIQUE_VALUES in lyr.py", line 18, in <module> arcpy.mapping.RemoveLayer(df, v) File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\utils.py", line 182, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\mapping.py", line 1845, in RemoveLayer assert isinstance(remove_layer, Layer) AssertionError >>>
I search desperately a solution to my problem -thanks