<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic change mxd reference from ArcGISonline Basemap Imagery to newly acquired imagery in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-mxd-reference-from-arcgisonline-basemap/m-p/257369#M19795</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How do I capture the source for the ArcGIS online Bing Imagery currently referenced in a series of mxds so as to change them to a newly acquired image source? I thought that maybe this data is cached and I could access that....not sure where to go from here, but the following code does not work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;refLayer = "C:\Users\my_user_name\AppData\Roaming\ESRI\Local Caches\MapCacheV1\maps.live.com_Aerial_en-US\MicrosoftVE" #my guess at the location of the ArcGISONLINE BING IMAGERY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;newImage = "G:\GIS\IMAGERY\8-28-2012_Ortho.tif"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r'G:\GIS\volume1.mxd')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for refLayer in arcpy.mapping.ListLayers(mxd, "Bing Maps Aerial", df):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.InsertLayer(df,refLayer,newImage,"BEFORE")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.RemoveLayer(df, refLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'finished'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Dec 2012 18:00:18 GMT</pubDate>
    <dc:creator>ChristopherOneal</dc:creator>
    <dc:date>2012-12-27T18:00:18Z</dc:date>
    <item>
      <title>change mxd reference from ArcGISonline Basemap Imagery to newly acquired imagery</title>
      <link>https://community.esri.com/t5/python-questions/change-mxd-reference-from-arcgisonline-basemap/m-p/257369#M19795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How do I capture the source for the ArcGIS online Bing Imagery currently referenced in a series of mxds so as to change them to a newly acquired image source? I thought that maybe this data is cached and I could access that....not sure where to go from here, but the following code does not work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;refLayer = "C:\Users\my_user_name\AppData\Roaming\ESRI\Local Caches\MapCacheV1\maps.live.com_Aerial_en-US\MicrosoftVE" #my guess at the location of the ArcGISONLINE BING IMAGERY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;newImage = "G:\GIS\IMAGERY\8-28-2012_Ortho.tif"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r'G:\GIS\volume1.mxd')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for refLayer in arcpy.mapping.ListLayers(mxd, "Bing Maps Aerial", df):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.InsertLayer(df,refLayer,newImage,"BEFORE")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.RemoveLayer(df, refLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'finished'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 18:00:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-mxd-reference-from-arcgisonline-basemap/m-p/257369#M19795</guid>
      <dc:creator>ChristopherOneal</dc:creator>
      <dc:date>2012-12-27T18:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: change mxd reference from ArcGISonline Basemap Imagery to newly acquired imagery</title>
      <link>https://community.esri.com/t5/python-questions/change-mxd-reference-from-arcgisonline-basemap/m-p/257370#M19796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just tested this using arcpy.mapping.UpdateLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I created a new MXD and added BingMapsAerial.&amp;nbsp; In the TOC, it is added as Basemap\BingMapsAerial.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I also added the Esri Imagery basemap (Basemap\World_Imagery).&amp;nbsp; I right clicked on the BaseMap group name and saved it out to a layer file (Basemap.lyr). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I removed the Esri basemap (I added it just to create the layer file).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Next I ran the following code from the Python window in ArcMap:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "Basemap")[0]&amp;nbsp; #this is the bing group layer
lyrFile = arcpy.mapping.Layer(r"C:\Temp\Basemap.lyr")
arcpy.mapping.UpdateLayer(df, lyr, lyrFile, False)
arcpy.RefreshActiveView()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:41:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-mxd-reference-from-arcgisonline-basemap/m-p/257370#M19796</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T12:41:12Z</dc:date>
    </item>
  </channel>
</rss>

