Select to view content in your preferred language

Infinity in Reclassify's RemapRange() ?

5150
1
Jump to solution
03-11-2015 01:26 PM
DavidWasserman
Frequent Contributor

Hi Python Community,
I have been using python for a few years now, but just recently started learning arcpy through Zandbergen's book.
I am trying to make a statistics based reclassification tool, and one of the elements I am using is the RemapRange object  (Takes in doubles) in ArcGIS 10.3.  I don't think the rest of the script is relevant, but the relevant portion is:

myremap=RemapRange([[0,Mean,9]......,[Mean+(Qrt_StD*7),float("inf"),1])

Now when I use infinity, this step is passed and no error is given. When I use a really large number like 1000000000000, it gives me the desired output.
My problem is a really large number is not a really robust solution, some forums, suggest ArcGIS might have problems with infinity in some circumstances, and the documentation does not mention infinity explicitly (understanding its limitations generally, is understandable).
My questions are:

1.WHat is the best way to represent "the end of the range" with a RemapRange ? Do you leave it blank? Some scripts do that, but that did not run or gave a syntax error when I tried it.

2.Is the best way to handle this to use a different function? Some suggested using the largest number possible for Floating points/doubles.
ANSWER:
For me what worked best was finding the max value property of the incoming raster and use that value +1.

3. What are reasonable ways to represent infinity in arcpy? (Is it just this object?)

4. Is there anything I could be missing?

Thanks,
David

David Wasserman, AICP
0 Kudos
1 Solution

Accepted Solutions
DavidWasserman
Frequent Contributor

I solved my own problem. Instead of using some default "high value" or float("inf"), I use the GetRasterProperties function to get the max value of the input raster being reclassified, and then use that (max+1) in the remap range object ( just to be sure... float point arithmetic etc).

Code below:

Max_Value_Result=arcpy.GetRasterProperties_management(EuDist_Ra_wStats,"MAXIMUM")
Max_Ra_Value=float(Max_Value_Result.getOutput(0))
arcpy.AddMessage("Max Raster Value is {0}.".format(Max_Ra_Value)) 
David Wasserman, AICP

View solution in original post

1 Reply
DavidWasserman
Frequent Contributor

I solved my own problem. Instead of using some default "high value" or float("inf"), I use the GetRasterProperties function to get the max value of the input raster being reclassified, and then use that (max+1) in the remap range object ( just to be sure... float point arithmetic etc).

Code below:

Max_Value_Result=arcpy.GetRasterProperties_management(EuDist_Ra_wStats,"MAXIMUM")
Max_Ra_Value=float(Max_Value_Result.getOutput(0))
arcpy.AddMessage("Max Raster Value is {0}.".format(Max_Ra_Value)) 
David Wasserman, AICP