I'm trying to remove WMS layers from an mxd using arcpy. I can successfully remove "MapServer" type services using the below code, but not WMS?
Here is an example mxd (zipped) with two different WMS layers that I'm trying to remove: here
Also, I've posted on the ArcGIS Resources forum too: here
import arcpy, os inFName = "wms.mxd" outFName = "wms_removed.mxd" pth = r"c:\temp" inFULLPTH = os.path.join(pth,inFName) outFULLPTH = os.path.join(pth,outFName) mxd = arcpy.mapping.MapDocument(inFULLPTH) for df in arcpy.mapping.ListDataFrames(mxd): LyrList = arcpy.mapping.ListLayers(mxd, "", df) for lyr in LyrList: if lyr.supports("SERVICEPROPERTIES"): if lyr.serviceProperties["ServiceType"] == "WMS": arcpy.mapping.RemoveLayer(df, lyr) mxd.saveACopy(outFULLPTH) del mxd
Any ideas? Is arcpy.mapping.RemoveLayer the best approach ? I have hundreds of mxds to crawl through and want to remove WMS layers from them.