<?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: Copying rasters to new geodatabase question in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154359#M11936</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IT was so simple, Thanks for your help!. I just changed it to CreateFileGDB management.&amp;nbsp; Thanks for all your help! Hopefully as I see more python, ill pick up on this more. I am working backwards through these exercises to I can see how python fits together.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Mar 2017 16:08:52 GMT</pubDate>
    <dc:creator>StephenTham</dc:creator>
    <dc:date>2017-03-30T16:08:52Z</dc:date>
    <item>
      <title>Copying rasters to new geodatabase question</title>
      <link>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154356#M11933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am new to ArcPy and python.&amp;nbsp; I am currently working on exercise 9.2 in Python Scripting for ArcGIS by Paul Zanbrtgen.&amp;nbsp; The question is pretty simple and is asking to write a scrip that copies rasters into a new Geodatabase.&amp;nbsp; I run print statements and everything is fine until I reach the&amp;nbsp; arcpy.CopyRaster_management(raster, outraster).&amp;nbsp; I am wondering if there is something wrong with the formatting of the file names. It throws a 999999 error.&amp;nbsp; How long did it take you to really become comfortable in the Arcpy environment and with python in general. My goal is to build python based geoprocessing tools one day.&amp;nbsp; &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; env
out_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:/EsriPress/Python/Data/Exercise09"&lt;/SPAN&gt;
env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; out_path
rasterlist &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListRasters&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreatePersonalGDB_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;out_path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/Results"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"myrasters.gdb"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; raster &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; rasterlist&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rname &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;baseName
&amp;nbsp;&amp;nbsp;&amp;nbsp; outraster &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; out_path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/Results/myrasters.gdb/"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; rname
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyRaster_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; outraster&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:14:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154356#M11933</guid>
      <dc:creator>StephenTham</dc:creator>
      <dc:date>2021-12-11T08:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Copying rasters to new geodatabase question</title>
      <link>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154357#M11934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not a Python guy, but a glance on your script, you are creating a Personal Geodatabase with extension .GDB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Either change the extension to MDB (i.e. myrasters.mdb)&lt;/P&gt;&lt;P&gt;2. or use arcpy.CreateFileGDB_management&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second one is more preferable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 15:43:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154357#M11934</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2017-03-30T15:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Copying rasters to new geodatabase question</title>
      <link>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154358#M11935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good for you picking up python and arcpy.&amp;nbsp; I took a class in grad school in python and arcpy and have used that same book myself before.&amp;nbsp; I didn't get too comfortable with it though til I found real applications for its use where I work and its been quite the timesaver for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now to your questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are getting the base name property of the raster but not an extension(file type).&amp;nbsp; Your output from Copy Raster will need a file type or it will default to a GRID file which has a 13 character limit and limits the character types that can be in the name.&amp;nbsp; This is likely causing your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also when joining paths and file names, I recommend using the os module and os.path.join to combine your path and name instead of concatenation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.python.org/2/library/os.path.html"&gt;https://docs.python.org/2/library/os.path.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 15:49:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154358#M11935</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-03-30T15:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Copying rasters to new geodatabase question</title>
      <link>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154359#M11936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IT was so simple, Thanks for your help!. I just changed it to CreateFileGDB management.&amp;nbsp; Thanks for all your help! Hopefully as I see more python, ill pick up on this more. I am working backwards through these exercises to I can see how python fits together.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 16:08:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/copying-rasters-to-new-geodatabase-question/m-p/154359#M11936</guid>
      <dc:creator>StephenTham</dc:creator>
      <dc:date>2017-03-30T16:08:52Z</dc:date>
    </item>
  </channel>
</rss>

