<?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 Re: Raster Layer Datasource not changable? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228778#M17738</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, so if I do replace the datasource of the layer in the MXD and then write the layer out to a layer file then the datasource is updated in the layer file but not in the MXD. Then I can load the layer file into the MXD and the datasource is update for that layer. That's silly but it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Feb 2016 18:28:24 GMT</pubDate>
    <dc:creator>DaveHighness</dc:creator>
    <dc:date>2016-02-23T18:28:24Z</dc:date>
    <item>
      <title>Raster Layer Datasource not changable?</title>
      <link>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228777#M17737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Map Document with a bunch of raster layers referenced by drive letter and need to change them to UNC paths. I've tried all the methods with the Map Document and by Layer to change the paths. The methods work for Feature Layers but not for the Raster Layers. If I add the layers manually to the map document they get added with the UNC path, then I can symbolize, rename and save. That is lame though!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this still a bug?&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/message/205282#comment-205282"&gt;https://community.esri.com/message/205282#comment-205282&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tried:&lt;/P&gt;&lt;P&gt;mxd.findAndReplaceWorkspacePaths()&lt;/P&gt;&lt;P&gt;mxd.replaceWorkspaces()&lt;/P&gt;&lt;P&gt;lay.replaceDataSource()&lt;/P&gt;&lt;P&gt;lay.findAndReplaceWorkspacePath()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Feb 2016 18:02:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228777#M17737</guid>
      <dc:creator>DaveHighness</dc:creator>
      <dc:date>2016-02-23T18:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Layer Datasource not changable?</title>
      <link>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228778#M17738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, so if I do replace the datasource of the layer in the MXD and then write the layer out to a layer file then the datasource is updated in the layer file but not in the MXD. Then I can load the layer file into the MXD and the datasource is update for that layer. That's silly but it works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Feb 2016 18:28:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228778#M17738</guid>
      <dc:creator>DaveHighness</dc:creator>
      <dc:date>2016-02-23T18:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Layer Datasource not changable?</title>
      <link>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228779#M17739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What version of ArcGIS are you using.&amp;nbsp; I have been able to replace rasters (see my addin &lt;A href="https://community.esri.com/migration-blogpost/55043" target="_blank"&gt;Python addin for data inventory and “broken-link” repair.&lt;/A&gt;​&amp;nbsp; for my full .py files) .&amp;nbsp; This could be modified to update non-broken links (I haven't done that yet)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a snippet for the raster (from repair broken link tool in my addin) ...it won't do much by itself, but might give you an idea.&amp;nbsp; To see it in context, check out the addin.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE: indentation of the first else removed for paste in geonet&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;else: #if lyr.supports("DATASOURCE") and lyr.supports("DATASETNAME"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; updateStatus = str(updatePath[0])&amp;nbsp;&amp;nbsp; # used for message only
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr in theTables:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #myMsgs("&amp;nbsp; thinks its a table....using findAndReplsWorkspacePath")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *Moving {0}: {1} to new: {2}".format(updatePath[3], lyr.dataSource, updatePath[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reportFile.write("\n&amp;nbsp;&amp;nbsp; Moving {0}: {1} to new: {2} \n".format(updatePath[3], lyr.dataSource, updatePath[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.findAndReplaceWorkspacePath(lyr.dataSource, updatePath, False)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif lyr.isRasterLayer:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #myMsgs("&amp;nbsp; thinks its a raster....using findAndReplsWorkspacePath")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsgs("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *Moving {0}: {1} to new: {2}".format(updatePath[3], lyr.dataSource, updatePath[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reportFile.write("\n&amp;nbsp;&amp;nbsp; Moving {0}: {1} to new: {2} \n".format(updatePath[3], lyr.dataSource, updatePath[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newType = "RASTER_WORKSPACE"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for extType in lstExtDatatype:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if extType[0] in updatePath[0]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newType = extType[1] 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if extType[0] == '.gdb':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newDSPath = newDSPath.split('.gdb', 1)[0] + '.gdb'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #newType = extType[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif extType[0] == '.sde':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newDSPath = newDSPath.split('.sde', 1)[0] + '.sde'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(newDSPath, newType, newDSName, False)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not sameType:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testOldTOC = updatePath[4].strip('\\')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.name == testOldTOC:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = lyr.datasetName
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newType = updatePath[1] &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw -- you can replace all&amp;nbsp;&amp;nbsp; "myMsgs" with "print"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:07:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228779#M17739</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T11:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Layer Datasource not changable?</title>
      <link>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228780#M17740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using 10.3.1 and tried essentially the same thing as seen in your code. For some reason the path will not change from drive letter to UNC in the MXD. Both paths are valid and point to the same FGDB so I'm wondering if that is the problem. Like I say if I write the Layer object out to a layer file then the layer file has the UNC path in it. I'm not sure if it's a bug or a feature.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Feb 2016 18:49:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-layer-datasource-not-changable/m-p/228780#M17740</guid>
      <dc:creator>DaveHighness</dc:creator>
      <dc:date>2016-02-23T18:49:21Z</dc:date>
    </item>
  </channel>
</rss>

