<?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: Using replaceDataSource to change geotiff file source? in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677147#M7292</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Aha!&amp;nbsp; This was driving me insane for hours.&amp;nbsp; I'm glad I stumbled upon this.&amp;nbsp; I was using 'name.img' with no success.&amp;nbsp; Changing it to 'name' fixed the problem.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Oct 2010 15:23:56 GMT</pubDate>
    <dc:creator>SeanRaffuse</dc:creator>
    <dc:date>2010-10-14T15:23:56Z</dc:date>
    <item>
      <title>Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677142#M7287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to take an existing mxd file and update it, automatically, with an updated raster layer. The rasters are geotiffs. However, I only get errors when I try to use replaceDataSource. Here is an example call, after I've setup "lyr" to point to the correct layer in the correct dataframe of the mxd:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; lyr.replaceDataSource("E:/Projects", "RASTER_WORKSPACE", "NewLayer_2010.tif")

Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;pyshell#20&amp;gt;", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; floodlayer.replaceDataSource("E:/Projects", "RASTER_WORKSPACE", "NewLayer_2010.tif")
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 179, in fn_
&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn(*args, **kw)
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\_mapping.py", line 559, in replaceDataSource
&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(self._arc_object.replaceDataSource(*gp_fixargs((workspace_path, workspace_type, dataset_name, validate), True)))
ValueError: Layer: Unexpected error&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have also tried using a Raster object, as returned by arcpy.Raster(filename), as the third parameter to this call, but also with no luck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to map automation in ArcGIS and arcpy - is what I'm trying to do simply not possible? Or is my syntax wrong, or I'm missing a critical step?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an alternative, I also tried inserting (or adding) a new Layer (arcpy.mapping.AddLayer). This works, but requires a layer object to be added/inserted -- it wont work on a geotiff file. And I cant figure out how to make a geotiff file into a layer object automatically. I can do so interactively in the ArcMap session (Save As Layer File), but I need to automate this. Is there a way to do this automatically?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or a better way all around to do what I'm trying to do? (Update one geotiff layer in mxd with a different one, where both have same size/extent/georeference etc just different values).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for any tips or hints.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:32:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677142#M7287</guid>
      <dc:creator>DanSlayback</dc:creator>
      <dc:date>2021-12-12T04:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677143#M7288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Daniel,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is your new raster in the same workspace (i.e., folder) as the old raster?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 15:18:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677143#M7288</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-10-13T15:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677144#M7289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Daniel,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try removing the extension from the file name.&amp;nbsp; Try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.replaceDataSource("E:/Projects", "RASTER_WORKSPACE", "NewLayer_2010")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This issue was addressed for SP1.&amp;nbsp; Please let me know if this does not work for you.&amp;nbsp; At SP1 you'll be able to use your original line of code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 15:48:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677144#M7289</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-10-13T15:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677145#M7290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, the raster was in the same directory - is that required?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wont have a chance to try it without the .tif until Monday, but will get back to you then if it works (or doesnt).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When is the SP1 expected out?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 16:16:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677145#M7290</guid>
      <dc:creator>DanSlayback</dc:creator>
      <dc:date>2010-10-13T16:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677146#M7291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It should not matter if the raster is in a different folder.&amp;nbsp; I was going to provide an alternative approach but then learned about the SP1 fix concerning the extension as part of the string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please keep us posted,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Oct 2010 19:10:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677146#M7291</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-10-13T19:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677147#M7292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Aha!&amp;nbsp; This was driving me insane for hours.&amp;nbsp; I'm glad I stumbled upon this.&amp;nbsp; I was using 'name.img' with no success.&amp;nbsp; Changing it to 'name' fixed the problem.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 15:23:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677147#M7292</guid>
      <dc:creator>SeanRaffuse</dc:creator>
      <dc:date>2010-10-14T15:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677148#M7293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, yes, that does it - Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, one additional issue: the replacement filename apparently cannot have any periods in it, except for the one indicating filetype. So, a file named test.tif will work (using simply "test" in replaceDataSource), but a file named test.abc.tif will not work (with "test.abc" in replaceDataSource). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is that expected behavior? Eg the only period in a filename should be the one indicating file type? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Oct 2010 12:50:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677148#M7293</guid>
      <dc:creator>DanSlayback</dc:creator>
      <dc:date>2010-10-20T12:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using replaceDataSource to change geotiff file source?</title>
      <link>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677149#M7294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the same problem too. My tif file name has a "." in it ("MN_Marine_on_St._Croix_20130807_TM_geo.tif"), the replacedatasource won't work! So I have to manually rename the file to make it work? Imagine I have hundreds of files... I am using 10.3.This seems to be an easy fix. ESRI, please.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 20:21:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-replacedatasource-to-change-geotiff-file/m-p/677149#M7294</guid>
      <dc:creator>JianLiu</dc:creator>
      <dc:date>2015-07-15T20:21:45Z</dc:date>
    </item>
  </channel>
</rss>

