How to identify Basemap layers in the ToC

749
4
07-28-2014 08:02 AM
AlbertoLaurenti
New Contributor III

Is there any way to identify a basemap layer in the ToC using python?

ArcGIS 10.1 - Python 2.7

Thanks in advance

0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor

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'

0 Kudos
AlbertoLaurenti
New Contributor III

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?

0 Kudos
JakeSkinner
Esri Esteemed Contributor

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'

0 Kudos
AlbertoLaurenti
New Contributor III

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.

0 Kudos