Is there any way to identify a basemap layer in the ToC using python?
ArcGIS 10.1 - Python 2.7
Thanks in advance
Hi Alberto,
Are you try to identify if an ESRI basemap is a layer within the TOC? One way to do this is to query the layer description. All of ESRI's basemap will have 'arcgisonline' at some point in the description. Ex:
if "arcgisonline" in layer.description:
print 'true'
Thank you Jake.
Yes, I'm looking a way to check if a basemap layer exists in the TOC. Unfortunately what you have suggested does not work: in my MXD I loaded an OpenStreetMap basemap layer and there is no "arcgisonline" word in its description.
Any other idea?
It looks like this is the only basemap that does not contain 'arcgisonline'. You could update the code to include 'openstreetmap'. Ex:
if "openstreetmap" or "arcgisonline" in layer.description:
print 'true'
Yes Jake,
in that way I can identify basemap layer... but only if default description is not modified! Furthermore I still can't identify custom basemaps.
Anyway, thanks again to have (partially) solved the problem.