[GIS] Reclassify variable in ModelBuilder

arcgis-desktoparcpymodelbuilder

I want to reclassify a raster (variable) in model builder in two classes. First class ist 0-treshold = NoData and second is treshold-max value = 1. It works fine if i use an existing raster file as input (where i can state and know the max value) but not for variables in ModelBuilder.

Any ideas how to do it in ModelBuilder, or with ArcPy?

This is my model in modelbuilder

EDIT:

Here is my edited model, but it's not running yet.

Edited model in modelbuilder

Best Answer

Try this:

Replace your reclassify step with the following steps:

  • Use the Get Raster Properties tool to retrieve the maximum value from your flow accummulation raster.
  • Use the Calculate Value tool and a python snippet to reclassify your flow accumulation raster.
  • Set the Data Type of the Calculate Value tool to "Raster Layer"
  • Define the following function in the code block

    def apply_threshold(flow_acc, max_flow,threshold, rcls_flow_path):
         rcls = arcpy.sa.Reclassify(flow_acc,"Value","0 {0} NODATA; {0} {1} 1".format(threshold,max_flow), "DATA")
         rcls.save(rcls_flow_path)
         return rcls_flow_path
    

The function defined above accepts a flow accummulation raster, max flow value, a threshold and an output path. Values 0 - threshold are reclassed to NODATA and values from threshold to max value are reclassed to 1.

See sample model below. enter image description here

  • Connect the reclassed flow accumulation to the rest of your model....