Make a copy of a raster dataset or loads raster datasets into a raster catalog. When storing a raster dataset in a geodatabase, no file extension should be.
Posted byGIS Technician
1 year agoI'm writing a script that as the title details is supposed to copy rasters from an existing folder to a geodatabase that the script is also creating. I'm running into an issue though on line 22 (arcpy.CopyRaster...) of the script where it pulls a 000601 error. The error message is telling me that it can't delete the geodatabase because it is locked by an application.
I call out at the top of the script the fact that I want to overwrite the files so that I can run it as necessary, but I don't want to just delete the database as a whole.
Can anyone provide any insight to me and help me figure out how to correct this?
Here is the script as it stands currently:
import arcpy
arcpy.env.overwriteOutput = True
from arcpy import env #Analysis environment
from arcpy.sa import * #import all tools
print 'Creating new geodatabase S:/GIS5103PythonExam/exam.gdb'
arcpy.CreateFileGDB_management ('S:/GIS5103PythonExam/', 'exam.gdb')
print 'Setting the workspace to the Exam geodatabase'
env.workspace = 'S:/Lab1/Lab7/partd/'
fclist = arcpy.ListFeatureClasses()
for fc in fclist:
rasterlist = arcpy.ListRasters()
for raster in rasterlist:
arcpy.CopyRaster_management(name, outname ,'DEFAULTS','0','9',',','8_BIT_UNSIGNED')
print name
print 'Copied all rasters successfully.'
6 comments