# set the workspace arcpy.env.workspace = r"C:\pathtomyworkspace" #set a different workspace arcpy.env.workspace = r"C:\pathtomydifferentworkspace" #clean up all items in the workspace fcs = arcpy.ListFeatureClasses() tabs = arcpy.ListTables() rasters = arcpy.ListRasters() ### for each FeatClass in the list of fcs's, delete it. for f in fcs: arcpy.Delete_management(f) arcpy.AddMessage("deleted: " + f) ### for each TableClass in the list of tab's, delete it. for t in tabs: arcpy.Delete_management(t) arcpy.AddMessage("deleted: " + t) ### for each Raster in the workspace, delete it for r in rasters: arcpy.Delete_management(r) arcpy.AddMessage("deleted " + str(r))
# set the workspace arcpy.env.workspace = r"C:\pathtomyworkspace" #set a different workspace arcpy.env.workspace = r"C:\pathtomydifferentworkspace" #clean up all items in the workspace fcs = arcpy.ListFeatureClasses() tabs = arcpy.ListTables() rasters = arcpy.ListRasters() ### for each FeatClass in the list of fcs's, delete it. for f in fcs: arcpy.Delete_management(f) arcpy.AddMessage("deleted: " + f) ### for each TableClass in the list of tab's, delete it. for t in tabs: arcpy.Delete_management(t) arcpy.AddMessage("deleted: " + t) ### for each Raster in the workspace, delete it for r in rasters: arcpy.Delete_management(r) arcpy.AddMessage("deleted " + str(r))
Post the code you percieve to be too slow for opinions or suggestions on how to improve it.
#After a series process, i get a raster, named myRaster, in Memory (3000 * 2500), whose cellsize is 0.25 * 0.25 path = r"C:\path" myRaster.save(path+"\\raster" )
import arcpy from arcpy.sa import * arcpy.CheckOutExtension("Spatial") myRaster = CreateRandomRaster(100, 0.25, Extent(0, 0, 750, 625)) path = r"C:\path" myRaster.save(path+"\\raster" )
Hi Zuoqi,
Try executing the following:import arcpy from arcpy.sa import * arcpy.CheckOutExtension("Spatial") myRaster = CreateRandomRaster(100, 0.25, Extent(0, 0, 750, 625)) path = r"C:\path" myRaster.save(path+"\\raster" )
How long does it take to execute?
It looks like it isn't the saving of the raster that is taking a long time, but the series of processes executed beforehand. Can you post your entire script?
#Create an empty Raster in Memory myRaster = Raster(dsm_file)*0 for i in (0,10): #Execute HillShade #myHillShadePath is the output Path and file name for HillShade myHillShadePath = r"C:/data/hillshade_"+str(i) myHill = Execute_HillShade(myHillShadePath ) myRaster = Execute_Raster(myHill ,myRaster ) #clean up the HillShade arcpy.Delete_management(outHillShadeRaster) #save the final raster myRaster.save(path)