0

I'm trying to create a model that uses as input a series of rasters created from elevation values in an original raster layer. To do this, I need some help figuring out how to generate these rasters.

I have a single raster with elevation values that I want to use the 'less than' tool on to generate a raster for each elevation value (the elevation range is from 0-140) from the original input. I can do this manually (such as typing in 'raster = Less than 15 ft'), but since my max-min range of elevation values is a fairly large number, it would be easier to find some way to do it as a batch, if it's possible, and output them to a geodatabase or folder.

As my results will end up in a model, I would like to do this in model builder if it's possible.
Is there a way to do this using something like an iterator on the 'less than' tool or even the raster calculator? The help I've been able to find so far on iterators relies on already having multiple rasters to go through.

1

What you want to iterate on is a list of elevation values to compare your DEMs for being less than.

This is pretty straight-forward in Python; I find the iteration abilities of ModelBuilder to be obtuse at best (in my opinion).

With a little editing to file paths and elevation values, and assuming your elevation values are in integers, the following should work in the ArcMap Python window.

import arcpy
from arcpy.sa import *
import os

arcpy.CheckOutExtension("Spatial")

# Your workspace folder
inDIR = "C:\\Users\\Me\\Somewhere"
# Your DEM in your workspace folder
inDEM = os.path.join( "C:\\Users\\Me\\Somewhere", "someDEM.tif")

myElevations = [10, 20, 30] # three example elevations in this case, can be many more.

for elev in myElevations:
    # Below, out files called, for example, lessthan10.tif, in your workspace folder.
    outDEM = os.path.join(inDIR, "lessthan" + str(elev) + ".tif")
    outLessThan = LessThan(inDEM, elev)
    outLessThan.save(outDEM)
    # To see progress in the Python window:
    print "Finished " + outDEM

If your rasters aren't GeoTiff files, edit the .tif bits, or delete them altogether if they're Esri GRID files (along with the '+' before it in the second instance).

  • Paulo, thanks so much for the code snippet. It looks like this will work great after trying it out. I still need to tweak a few things, but this has been a big help. I'm also going to try Tangnar's option (above) to see if I can replicate this in modelbuilder, but Python is definitely a nice option here. Quick fix! – AKubes Nov 13 '15 at 20:44
1

I agree with Paulo that iterating in python is easier. However, there is a Model Builder tool called Iterate MultiValue. Looks like you can connect it to whatever tool you need and it's function is to iterate through the values that you give it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.