Cross posting: Python
I'm writing a python tool that given a elevation raster (elevation value in meters), converts to a "raster object" with elevation value in feet. I then create a variable based on elevation Range provided be the user to be used with the Reclassify command as a RemapRange. The result of this Reclassify (and maybe one other step eventually) will be input to RasterToPolygon
I've included a very simplified version of the code I have,
The out value of my reclassArg is
[[327.850126532, 1000, 1000], [1000, 2000, 2000], [ 2000, 3000, 3000], [ 3000, 6500, 6500]]
But I have also tried version such as
327.850126532 1000 1000; 1000 2000 2000; 2000 3000 3000; 3000 6500 6500
and all different variations of the two, based on the "results" snippet, and various help docs.
I've tried quite a few different commands and versions of the reclassArg, with the last being from the local ArcGIS 10.3 tool help

But my output raster keeps come out with a single value 127. Full disclosure, before I tried
outDEMtmp = Reclassify(elevFeet, "Value", RemapRange("{0}".format(reclassArg)), "NODATA")
or
outDEMtmp = arcpy.sa.Reclassify(elevFeet, "Value", RemapRange("{0}".format(reclassArg)), "NODATA")
and even
arcpy.gp.Reclassify_sa(elevFeet, "Value", reclassArg, outDEMtmp, "NODATA")
The first two (using the [[ ]] list as reclassArg) finishes without an erro, but all values are are "127"
The third option is not reclassifying anything.
I admit my spatial analyst skills are very rusty, and the raster-object concept is new (all though similar to the old GRID), but I'm running out of ideas to try, other than running the tools manually. Any help or a good resource on scripting the Reclassify tool would be helpful.
Using 10.3, ArcInfo/Advanced and Spatial Analyst (I have access to 3D if needed).
import os
import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("spatial")
theWorkspace = r"C:\_beartest\Prep.gdb"
arcpy.env.workspace = theWorkspace
arcpy.env.overwriteOutput = True
wsPath, wsGDB = os.path.split(theWorkspace)
rasterIn = r"C:\_beartest\Unit20Araster.gdb\elevClip"
toElevFeet = 3.280839895013123
elevFeet = (Raster(rasterIn) * toElevFeet)
elevMinimum = elevFeet.minimum
elevCutoffFt = "6500"
flatElevBreak = ("1000; 2000; 3000")
# processing the elevation and high-cuttoff variables to create reclass arguments
elevSplit = flatElevBreak.split(";")
lstCnt = 1
for reclassValue in elevSplit:
print(reclassValue)
print("Reclass value:{0} ft".format(reclassValue))
if lstCnt == 1:
reclassArg = ("[[{0}, {1}, {2}]".format(elevMinimum, reclassValue, ("{0}".format(reclassValue))))
else:
reclassArg = ("{0}, [{1}, {2}, {3}]".format(reclassArg, prevValue, reclassValue, ("{0}".format(reclassValue))))
lstCnt += 1
prevValue = reclassValue
reclassArg = ("{0}, [{1}, {2}, {3}]]".format(reclassArg, prevValue, elevCutoffFt, ("{0}".format(elevCutoffFt))))
print(reclassArg)
outDEMtmp = arcpy.sa.Reclassify(elevFeet, "Value", RemapRange("{0}".format(reclassArg)), "NODATA")
outDEMtmp.save(elevReclass)
print("hello2")
#arcpy.RasterToPolygon_conversion(outDEMtmp, "reclassPoly", "SIMPLIFY", "VALUE")
arcpy.CheckInExtension("spatial")
Suggestions would be greatly appreciated. Thanks
EDIT: added line 18 which was missing.
Message was edited by: Rebecca Strauch, GISP
EDIT: added line 18 which was missing.