<?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: Renaming and Copying Raster Data in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239112#M18608</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting an error now when calling the module.&amp;nbsp;Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp; &amp;nbsp;File "&amp;lt;string&amp;gt;", line 43, in &amp;lt;module&amp;gt;&amp;nbsp; &amp;nbsp;File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 12583, in CopyRaster&amp;nbsp; &amp;nbsp; &amp;nbsp;raise e ExecuteError: ERROR 000732: Input Raster: Dataset newFile does not exist or is not supported&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;filCnt = 0&lt;BR /&gt;for file in files:&lt;BR /&gt; # Slice off 1st 4 digits of file name&lt;BR /&gt; num = file[0:4]&lt;BR /&gt; if num == "1982":&lt;BR /&gt; filCnt = filCnt + 1&lt;BR /&gt; sStg = 0&lt;BR /&gt; sStg = file.find('L') # A few files contain L&lt;BR /&gt; if sStg &amp;gt; 8 and sStg &amp;lt; 15:&lt;BR /&gt; newFile = file[sStg+2:]&lt;BR /&gt; arcpy.CopyRaster_management("newFile+.tif", "outDir", "DEFAULTS" , "" , "" , "" , "" , "")&lt;BR /&gt; print "Processing..." +newFile&lt;/P&gt;&lt;P&gt;sStg = file.find('l') # A few files contain l&lt;BR /&gt; if sStg &amp;gt; 8 and sStg &amp;lt; 15:&lt;BR /&gt; newFile = file[sStg+2:]&lt;BR /&gt; arcpy.CopyRaster_management("newFile+.tif", "outDir", "DEFAULTS" , "" , "" , "" , "" , "")&lt;BR /&gt; print "Processing..." +newFile&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What do I need to do here??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Dec 2017 22:04:46 GMT</pubDate>
    <dc:creator>PeterBordokoff2</dc:creator>
    <dc:date>2017-12-15T22:04:46Z</dc:date>
    <item>
      <title>Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239108#M18604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a script to rename and copy a large raster data set, in folders containing .prj, .tfwx, .tif.aux.xml, .ovr, and .tif.xml files with each .tif image. In running a simple rename and shutil.copy script (below) I lose parts of the metadata:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;filCnt = 0&lt;BR /&gt;for file in files:&lt;BR /&gt; # Slice off 1st 4 digits of file name&lt;BR /&gt;&amp;nbsp; &amp;nbsp; num = file[0:4]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if num == "1982":&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; filCnt = filCnt + 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sStg = 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sStg = file.find('L') # A few files contain L&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if sStg &amp;gt; 8 and sStg &amp;lt; 15:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newFile = file[sStg+2:]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;shutil.copy(file,outDir+newFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print newFile&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sStg = file.find('l') # A few files contain l&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if sStg &amp;gt; 8 and sStg &amp;lt; 15:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newFile = file[sStg+2:]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;shutil.copy(file,outDir+newFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print newFile&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;How can I modify this to keep the renaming convention, but use another copying procedure? The Copy Raster tool ignores the associated files and I would prefer not creating a database for this, given the amount of data. Any ideas? Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running 10.3 btw&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 19:57:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239108#M18604</guid>
      <dc:creator>PeterBordokoff2</dc:creator>
      <dc:date>2017-12-15T19:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239109#M18605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Copy Raster tool should retain this all associated files.&amp;nbsp; Before executing the tool go into Environments &amp;gt; Raster Storage.&amp;nbsp; Make sure 'Build Pyramids' and 'Calculate Statistics' are checked.&amp;nbsp; This should preserver the .aux.xml and .ovr files.&amp;nbsp; The projection information should be stored in the header of the TIFF so it will be okay if there is no .prj file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 20:15:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239109#M18605</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2017-12-15T20:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239110#M18606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is the best order of operations to achieve this? Can I call the tool on the same line as the shutil.copy command? Or, do I need another block?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 20:28:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239110#M18606</guid>
      <dc:creator>PeterBordokoff2</dc:creator>
      <dc:date>2017-12-15T20:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239111#M18607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Copy Raster tool will copy the raster to the new location, and you can rename it using this tool as well.&amp;nbsp; No need to implement the shutil.copy command.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 20:40:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239111#M18607</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2017-12-15T20:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239112#M18608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting an error now when calling the module.&amp;nbsp;Runtime error&amp;nbsp; Traceback (most recent call last):&amp;nbsp; &amp;nbsp;File "&amp;lt;string&amp;gt;", line 43, in &amp;lt;module&amp;gt;&amp;nbsp; &amp;nbsp;File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 12583, in CopyRaster&amp;nbsp; &amp;nbsp; &amp;nbsp;raise e ExecuteError: ERROR 000732: Input Raster: Dataset newFile does not exist or is not supported&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;filCnt = 0&lt;BR /&gt;for file in files:&lt;BR /&gt; # Slice off 1st 4 digits of file name&lt;BR /&gt; num = file[0:4]&lt;BR /&gt; if num == "1982":&lt;BR /&gt; filCnt = filCnt + 1&lt;BR /&gt; sStg = 0&lt;BR /&gt; sStg = file.find('L') # A few files contain L&lt;BR /&gt; if sStg &amp;gt; 8 and sStg &amp;lt; 15:&lt;BR /&gt; newFile = file[sStg+2:]&lt;BR /&gt; arcpy.CopyRaster_management("newFile+.tif", "outDir", "DEFAULTS" , "" , "" , "" , "" , "")&lt;BR /&gt; print "Processing..." +newFile&lt;/P&gt;&lt;P&gt;sStg = file.find('l') # A few files contain l&lt;BR /&gt; if sStg &amp;gt; 8 and sStg &amp;lt; 15:&lt;BR /&gt; newFile = file[sStg+2:]&lt;BR /&gt; arcpy.CopyRaster_management("newFile+.tif", "outDir", "DEFAULTS" , "" , "" , "" , "" , "")&lt;BR /&gt; print "Processing..." +newFile&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What do I need to do here??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 22:04:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239112#M18608</guid>
      <dc:creator>PeterBordokoff2</dc:creator>
      <dc:date>2017-12-15T22:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239113#M18609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried it without an extension, I realize above it should be "newFile"+.tif, but it is not working&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 22:07:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239113#M18609</guid>
      <dc:creator>PeterBordokoff2</dc:creator>
      <dc:date>2017-12-15T22:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239114#M18610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyRaster_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Path to Original Raster + Raster name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Path to New Location + New raster name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyRaster_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Raster\Original.tif"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\Raster\New.tif"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Dec 2017 13:10:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239114#M18610</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2017-12-21T13:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239115#M18611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can successfully rename the .tif files, but when I call CopyRaster_management I get an error that the input Raster doesn't exist or is not compatible. Is there an order of operations I am unaware of? Do the files need to be written to a folder after renaming them before moving them?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Dec 2017 23:34:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239115#M18611</guid>
      <dc:creator>PeterBordokoff2</dc:creator>
      <dc:date>2017-12-26T23:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming and Copying Raster Data</title>
      <link>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239116#M18612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suggest you to use arcpy.Rename_management if your raster files don't contain .dre files. Also&amp;nbsp;you can use fnmatch and os to list and find your raster with extension you specified. For example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;def &lt;/SPAN&gt;&lt;SPAN style="color: #ffc66d;"&gt;Rasterlist&lt;/SPAN&gt;(folder):
&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterlarunisiz = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; numberoffiles = &lt;SPAN style="color: #8888c6;"&gt;len&lt;/SPAN&gt;(fnmatch.filter(os.listdir(folder)&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'*.tif'&lt;/SPAN&gt;))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;"count of files:%s" &lt;/SPAN&gt;% numberoffiles)
&amp;nbsp;&amp;nbsp;&amp;nbsp; unilirasterlar = fnmatch.filter(os.listdir(folder)&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;'*.tif'&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;"unicode rasters:%s" &lt;/SPAN&gt;% unilirasterlar)
&amp;nbsp;&amp;nbsp;&amp;nbsp; ranger = &lt;SPAN style="color: #8888c6;"&gt;range&lt;/SPAN&gt;(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;dosyasayisi)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;i &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;ranger:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterlarnameunisiz = unilirasterlar&lt;I&gt;.encode(&lt;SPAN style="color: #a5c261;"&gt;'UTF-8'&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rasterlarunisiz.append(rasterlarnameunisiz)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;"rasters without unicode: %s " &lt;/SPAN&gt;% rasterlarunisiz)&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;Besides, you shouldn't worry about .ovr and,&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;.tif.aux.xml etc.. Because most of those files was created by making pyramids on associated rasters.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;And use Pycharm, use def.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:02:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-and-copying-raster-data/m-p/239116#M18612</guid>
      <dc:creator>UMUTÜÇOK</dc:creator>
      <dc:date>2021-12-11T12:02:24Z</dc:date>
    </item>
  </channel>
</rss>

