AnsweredAssumed Answered

Copying rasters to new geodatabase question

Question asked by yankees3490 on Mar 30, 2017
Latest reply on Mar 30, 2017 by yankees3490

I am new to ArcPy and python.  I am currently working on exercise 9.2 in Python Scripting for ArcGIS by Paul Zanbrtgen.  The question is pretty simple and is asking to write a scrip that copies rasters into a new Geodatabase.  I run print statements and everything is fine until I reach the  arcpy.CopyRaster_management(raster, outraster).  I am wondering if there is something wrong with the formatting of the file names. It throws a 999999 error.  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. 

import arcpy
from arcpy import env
out_path = "C:/EsriPress/Python/Data/Exercise09"
env.workspace = out_path
rasterlist = arcpy.ListRasters()
arcpy.CreatePersonalGDB_management(out_path + "/Results", "myrasters.gdb")
for raster in rasterlist:
    desc = arcpy.Describe(raster)
    rname = desc.baseName
    outraster = out_path + "/Results/myrasters.gdb/" + rname
    arcpy.CopyRaster_management(raster, outraster)