2

I have many mxds that previously used ArcGIS Online Bing imagery. I want to replace those with newly purchased imagery. I know I need to use the arcpy.mapping.MapDocument module to do this though not sure how. However when I try to identify the source for the online imagery it is listed as 'source unknown'. Script snippet below shows how I am trying to identify sources in each mxd which I am writing to a .csv

for map in mxd_list:
mxd = arcpy.mapping.MapDocument(map)
layers = arcpy.mapping.ListLayers(mxd, '*')
for i in layers:
    try:
        ds = i.dataSource
    except:
        ds = 'source unknown'
    writer.writerow([map, i.name,  ds ])
PolyGeo
  • 65,136
  • 29
  • 109
  • 338

1 Answers1

1

The Bing Maps basemap does not seem to qualify as a Service Layer but you should be able to recognise it by its longName.

If you have a single Bing Maps Aerial layer in a test.mxd then ...

import arcpy

mxd = arcpy.mapping.MapDocument("C:/temp/test.mxd")
layers = arcpy.mapping.ListLayers(mxd, '*')
for i in layers:
    print i.name
    print i.isServiceLayer
    print i.longName

will return something like ...

>>> ================================ RESTART ================================
>>> 
Basemap
False
Basemap
BingMapsAerial
False
Basemap\BingMapsAerial
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • isServiceLayer is great start....Im running 10.0 thoughso that module is not there.... something like the following is what I am aiming for, however, without a way to reference the object i.e. refLayer, I cant remove it via .RemoveLayer – chris oneal Dec 29 '12 at 01:44