Raster Calculator for Python Script

Discussion created by deana444 on Jun 27, 2013
Latest reply on Jul 1, 2013 by deana444
I cannot get a conditional evaluation calculation to be done on two rasters.

I want an ouput raster to be created from the positive difference of two rasters (so no negative numbers)

The part of the code that isn't working

import arcpy
import os
from arcpy import env
from import *
import arcgisscripting

I've tried two different ways, both failing

Method one

        arcpy.AddMessage("Creating Elevation Raster")
env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
elevation = Con(list[1]-list[0]>=0, list[1]-list[0],0)

Method two
arcpy.AddMessage("Creating Elevation Raster")
expression = "Con({}-{}>=0, {}-{},0)".format(list[1], list[0], list[1], list[0])
OR = "elevation3"
OutRaster = os.join.path(FD_addr,OR)
gp = arcgisscripting.create()
gp.SingleOutputMapAlgebra_sa(expression, OutRaster)

my list has two rasters (I've checked to make sure they are there): a DSM and a DEM, and I want to find the positive elevation difference between the two.

Any help would be appreciated! I've been stuck on this for ages.