1

I'm trying to create a python script tool that will take in a DEM/raster as a parameter, pull out the maximum and minimum elevation values, and iterate through this range of values at a specified counting interval.

This script outputs the resulting raster masks to an output geodatabase, as another parameter. I keep getting the error '000865: Input Raster: inDEM does not exist' when I try to run my script tool. I'd like help resolving this issue in my code, as I'm not sure what the cause is.

import arcpy
from arcpy.sa import *
import os
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True
inDEM = arcpy.GetParameterAsText(0)
intervalElevation = int(arcpy.GetParameterAsText(1))
outGDB = arcpy.GetParameterAsText(2)
elevMinResult = arcpy.GetRasterProperties_management("inDEM", "MINIMUM")
elevMaxResult = arcpy.GetRasterProperties_management("inDEM", "MAXIMUM")
minElevation = elevMinResult.getOutput(0)
maxElevation = elevMaxResult.getOutput(0)
myElevations = range(minElevation, maxElevation, intervalElevation)
for elev in myElevations:
 outDEM = os.path.join(outGDB, "lessthan" + str(elev))
 outLessThan = LessThan(inDEM, elev)
 outLessThan.save(outDEM)
 print "Finished " + outDEM
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 4, 2016 at 16:31

1 Answer 1

2

You are getting the name of the input raster with this line and assigning it to a variable inDEM:

inDEM = arcpy.GetParameterAsText(0)

But in this line you are proving a string.

elevMinResult = arcpy.GetRasterProperties_management("inDEM", "MINIMUM")

As you have the name of the raster in the variable all you need to do is remove the double quotes around "inDEM" and you are referencing the variable which is holding the true raster layer name.

answered Jan 4, 2016 at 16:56
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.