Reclassify in Arcpy creates erroneous values?

1628
3
Jump to solution
04-26-2012 09:25 AM
RichardThurau
Occasional Contributor
Hi,
This post could go under a previous thread I started under the heading "Why does Python suck?", but want to start off fresh.

I am trying to reclassify NoData values to zero for two rasters that each have a single value.

import arcpy, os from arcpy.sa import * from arcpy import env arcpy.CheckOutExtension("Spatial") arcpy.env.overwriteOutput = True  ws = arcpy.env.workspace=r"X:\DATA\Raster_LC.gdb" arcpy.env.extent = r"X:\DATA\Raster_LC.gdb\Study_Area_ras" arcpy.env.mask = r"X:\DATA\Raster_LC.gdb\Study_Area_ras" arcpy.env.snapRaster = r"X:\DATA\Raster_LC.gdb\Study_Area_ras"  #####  Following section Converts nodata to 0 values within the extent of the above mask.     TreeAd = Reclassify("New_Trees", "Value", RemapValue ([["NODATA", 0], [700, 1000]])) TreeAd.save("Trees_Ad_0") TreeAd = "Trees_Ad_0" TreeErase = Reclassify("Remove_Trees", "Value", RemapValue ([["NODATA", 0], [100, 30]])) TreeErase.save("Tree_Erase_0") TreeErase = "Tree_Erase_0"


"New_Trees" is a single value raster (700) and "Remove_Trees" is a single value raster (100). I use the study area extent, mask, and snap raster to define the extent of my NoData conversion.

Attribute tables: Should be ; Actually produced
"Trees_Ad_0": 0, 1000; 9, 1000 - Where does the 9 come from?
"Trees_Erase_0": 0, 30; 29, 30 - Where does the 29 come from?

I'd love to know why this happens (has happened in the past), and
How do I prevent this from happening?

Many thanks.

Rich
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Rich,

I found that if you specify the NoDATA value last, you won't run into this issue.  Try the following:

import arcpy, os from arcpy.sa import * from arcpy import env arcpy.CheckOutExtension("Spatial") arcpy.env.overwriteOutput = True  ws = arcpy.env.workspace=r"X:\DATA\Raster_LC.gdb" arcpy.env.extent = r"X:\DATA\Raster_LC.gdb\Study_Area_ras" arcpy.env.mask = r"X:\DATA\Raster_LC.gdb\Study_Area_ras" arcpy.env.snapRaster = r"X:\DATA\Raster_LC.gdb\Study_Area_ras"  #####  Following section Converts nodata to 0 values within the extent of the above mask.     TreeAd = Reclassify("New_Trees", "Value", RemapValue ([[700, 1000], ["NODATA", 0]])) TreeAd.save("Trees_Ad_0") TreeAd = "Trees_Ad_0" TreeErase = Reclassify("Remove_Trees", "Value", RemapValue ([[100, 30], ["NODATA", 0]])) TreeErase.save("Tree_Erase_0") TreeErase = "Tree_Erase_0"

View solution in original post

0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Rich,

I found that if you specify the NoDATA value last, you won't run into this issue.  Try the following:

import arcpy, os from arcpy.sa import * from arcpy import env arcpy.CheckOutExtension("Spatial") arcpy.env.overwriteOutput = True  ws = arcpy.env.workspace=r"X:\DATA\Raster_LC.gdb" arcpy.env.extent = r"X:\DATA\Raster_LC.gdb\Study_Area_ras" arcpy.env.mask = r"X:\DATA\Raster_LC.gdb\Study_Area_ras" arcpy.env.snapRaster = r"X:\DATA\Raster_LC.gdb\Study_Area_ras"  #####  Following section Converts nodata to 0 values within the extent of the above mask.     TreeAd = Reclassify("New_Trees", "Value", RemapValue ([[700, 1000], ["NODATA", 0]])) TreeAd.save("Trees_Ad_0") TreeAd = "Trees_Ad_0" TreeErase = Reclassify("Remove_Trees", "Value", RemapValue ([[100, 30], ["NODATA", 0]])) TreeErase.save("Tree_Erase_0") TreeErase = "Tree_Erase_0"
0 Kudos
RichardThurau
Occasional Contributor
Thanks Jake, that did the trick. I am interested in the why, simply because if I had used these values in a combination with other values and set up a reclassify based on anticipated outputs, I would never have known this issue occurred. If this method always works, I'm not worried about it. But does reclassify ever deliver erroneous values even when NoData is last?

Thanks for the reply.

Rich
0 Kudos
JakeSkinner
Esri Esteemed Contributor
I was unable to get erroneous results when NoDATA was listed last.  I'm not sure if NoDATA has to be listed last by design, or if this is a bug.  If you like, you can follow up with this issue by logging an incident with Tech Support.
0 Kudos