import arcpy import os from arcpy import env from arcpy.sa import * arcpy.CheckOutExtension("Spatial") # for arcpy.sa env.workspace = FD_addr # DEM/DSM raster locations raster_list = arcpy.ListRasters("*", "ALL") # adds DEM/DSM raster size = len(raster_list) #### Make some exception here if != 2 raster0 = arcpy.Raster(raster_list[0]) raster1 = arcpy.Raster(raster_list[1]) elevation = arcpy.sa.Con(raster1-raster0 >= 0, raster1-raster0,0) elevation.save("elevation") # saved in FD_addr
print elevation print raster0 print raster1
elevation = Con("Surface_RAS"-"Ground_RAS">=0,"Surface_RAS"-"Ground_RAS",0)
arcpy.gp.RasterCalculator_sa("""elevation = Con("Surface_RAS"-"Ground_RAS">=0,"Surface_RAS"-"Ground_RAS",0)""","C:/Summer_13/Geo.gdb/elevation")
Not really sure how to see Arcmessages as I do everything in the command line, and not really familiar with the Arc command window/python tools.
How are you running this? In the command window, or making a script tool or what?
If running in console window, after it runs, if you type:print elevation print raster0 print raster1
do you get any results?
also, can you create the elevation raster that you are after within arcmap using the tools? I am wondering if it is creating an empty output, so is not saving it.
I would make sure that it is possible to do what you are trying using arcmap tools/model and get the desired output. then work on the python code (export from the model builder and modify).
Might also look into the DEM format. I have tried to use this in the past for certain tasks, and found that it does not support state plane coordinates. Perhaps one of the input rasters is not supported or valid for this operation? If you can do the raster calculations in ArcMap, then that would rule this out as well.
R_
arcpy.gp.RasterCalculator_sa("""elevation = Con("Surface_RAS"-"Ground_RAS">=0,"Surface_RAS"-"Ground_RAS",0)""","C:/Summer_13/Geo.gdb/elevation")
DEM = arcpy.Raster(raster_list[0]) DSM = arcpy.Raster(raster_list[1]) expression = """elevation = Con({}-{}>=0,{}-{},0)""".format(DSM,DEM,DSM,DEM) raster_out = os.path.join(FD_addr,"elevation") arcpy.gp.RasterCalculator_sa(expression,raster_out)
env.workspace = FD_addr # DEM/DSM raster locations
raster_list = arcpy.ListRasters("*", "ALL") # adds DEM/DSM raster
What I meant by using ArcMap tools, was not actually using the raster calculator, but the spatial analys "Con" tool.
What I would do is open ArcMap, open the catalog window, right-click on Toolbox (or My Toolboxes) folder and choose "New" Model.