I'm trying to get RemapRange to accept a variable as input for the remap statement. The reason I need to do this is the input is variable based on user input. The reclassify statement in the code block below does not accept this input.
When I check DirRange it outputs [[157,166,1],[166,175,2],[175,184,3],[184,193,2],[193,202,1]]. This assumes Direction = 180
However when I check DirRemap I get [; [; 1; 5; 7; ,; 1; 6; 6; ,; 1; ]; ,; [; 1; 6; 6; ,; 1; 7; 5; ,; 2; ]; ,; [; 1; 7; 5; ,; 1; 8; 4; ,; 3; ]; ,; [; 1; 8; 4; ,; 1; 9; 3; ,; 2; ]; ,; [; 1; 9; 3; ,; 2; 0; 2; ,; 1; ]; ]
How do I get Remap to give the correct value or get Reclassify to accept the input?
import arcpy
from arcpy.sa import *
Direction = arcpy.GetParameterAsText(0)
Dirout = arcpy.GetParameterAsText(1)
DirMin = Direction - 23
DirMax = Direction + 22
if DirMin <= 0:
DirMin = DirMin + 360
else:
DirMin = DirMin
if DirMax >= 360:
DirMax = DirMax - 360
else:
DirMax = DirMax
Part1 = DirMin + 9
if Part1 >= 360:
Part1 = Part1 - 360
Part2 = Part1 + 9
if Part2 >= 360:
Part2 = Part2 - 360
Part3 = Part2 + 9
if Part3 >= 360:
Part3 = Part3 - 360
Part4 = Part3 + 9
if Part4 >= 360:
Part4 = Part4 - 360
Cat1 = "[" + str(DirMin) + "," + str(Part1) + ",1],"
Cat2 = "[" + str(Part1) + "," + str(Part2) + ",2],"
Cat3 = "[" + str(Part2) + "," + str(Part3) + ",3],"
Cat4 = "[" + str(Part3) + "," + str(Part4) + ",2],"
Cat5 = "[" + str(Part4) + "," + str(DirMax) + ",1]"
DirRange = "[" + Cat1 + Cat2 + Cat3 + Cat4 + Cat5 + "]"
DirRemap = RemapRange(DirRange)
DRaster = arcpy.sa.Reclassify(Dirout, "Value", DirRemap, "NODATA")