I'm trying to save filled raster object to geo database by my specified filename.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = r"C:\GIS Data\Cameron_Run\Topo_NED\Projected"
# Set local variables
surfaceRaster = "raw_10m_dem"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute FlowDirection
fillRaster = Fill(surfaceRaster)
arcpy.RasterToGeodatabase_conversion(fillRaster, r"C:\GIS Data\Cameron_Run\Topo_NED
\Projected\fillRasterGDB.gdb")
But this code is saving raster file by its own specified name, for this case Fill_raw_10m1
is the default name of saved raster file.
Is there any way so that I can specify the name of saved raster file?
Best Answer
It looks like you've looked at ESRI's example because your comment says "Execute FlowDirection" - which is the error in ESRI's docs, but I'll pull out the important part that your code is missing - the save() method for your fill object.
Generally, the Spatial Analyst tools work a little differently in scripting than some of the other toolbox tools since they generate a return value that is an object (rather than taking input and output locations). Once you have the Fill object living in memory, you can save it using the object's save method. So, in your code above:
So, just run save, and pass in a location in order to specify where it goes. My understanding is that the RasterToGeodatabase tool doesn't accept Spatial Analyst objects as inputs.