I'm trying to batch reclassify a set of rasters in ModelBuilder by assigning an interger from 1-8. So if raster value is 1-1.5 =1.5-2.5=3, ...... 7.5-8=8
I know I can put these values in a table, but it would be nice to embed it in the model for portability.
If you want to do it directly with Python, here's an example. Bear in mind that this works on integer rasters, so you will need to modify the remap table function.
# Name: reclassify_example02.py # Description: Reclassifies the values in a raster. # Requirements: Spatial Analyst Extension # Author: ESRI, modified by Brian Cohen
# Import system modules import arcpy from arcpy import env from arcpy.sa import * import os
# Set environment settings env.workspace = "N:/South_Coast/Geo_Data/Climate/SDMs/plantsout" count = 0
# Get list of rasters from workspace rasterList = arcpy.ListRasters("*", "All")
# sort alphabetically rasterList.sort()
for inRaster in rasterList:
# set the reclassify field reclassField = "Value"
# create the remap value table (here, changing all values to 0 save for 1, which remains the same) remap = RemapValue([[0, 0], [1, 1],[2, 0],[3, 0],[4, 0],[5, 0],[6, 0],[7, 0]])
# Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial")
If you want to do it directly with Python, here's an example. Bear in mind that this works on integer rasters, so you will need to modify the remap table function.
# Name: reclassify_example02.py # Description: Reclassifies the values in a raster. # Requirements: Spatial Analyst Extension # Author: ESRI, modified by Brian Cohen
# Import system modules import arcpy from arcpy import env from arcpy.sa import * import os
# Set environment settings env.workspace = "N:/South_Coast/Geo_Data/Climate/SDMs/plantsout" count = 0
# Get list of rasters from workspace rasterList = arcpy.ListRasters("*", "All")
# sort alphabetically rasterList.sort()
for inRaster in rasterList:
# set the reclassify field reclassField = "Value"
# create the remap value table (here, changing all values to 0 save for 1, which remains the same) remap = RemapValue([[0, 0], [1, 1],[2, 0],[3, 0],[4, 0],[5, 0],[6, 0],[7, 0]])
# Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial")