Hello all,
I am new to Arcgis and python scripting ,
I have a database and I want to delete all temporary created rasters in it. Doe's anybody know how to perform this task by python code?
Solved! Go to Solution.
I haven't tested the code, but I guess this should work:
import arcpy
# settings
gdb = r"C:\Path\to\your\FileGeodatabase.gdb"
arcpy.env.workspace = gdb
# create a list of rasters in the folder
rasters = arcpy.ListRasters()
# loop through raster in list
for raster in rasters:
try:
arcpy.Delete_management(raster)
except:
print "Raster '{0}' could not be deleted".format(raster)
Kind regards, Xander
I haven't tested the code, but I guess this should work:
import arcpy
# settings
gdb = r"C:\Path\to\your\FileGeodatabase.gdb"
arcpy.env.workspace = gdb
# create a list of rasters in the folder
rasters = arcpy.ListRasters()
# loop through raster in list
for raster in rasters:
try:
arcpy.Delete_management(raster)
except:
print "Raster '{0}' could not be deleted".format(raster)
Kind regards, Xander
Thank you Xander. The code works!
Sara