Inconsistent results from SetNull

03-23-2016 08:48 AM
Regular Contributor


I get different results from a SetNull operation when I run it in a python script compared to a python toolbox.  The inputs are exactly the same and the scripts are the same except one has been converted into a python toolbox.

My input is a raster made up of ones and zeros, I then use SetNull to set the zeros to nulls - I then use RasterToPolygon so I get a shape where all the ones were.

In the python script this runs correctly.

However, in the python toolbox the output of the SetNull initially looks correct but if I go into symbology and turn on 'all other values' I can see that instead of nulls the zeros are either still zero or have value= -128.  This means that when the RasterToPolygon runs I get unwanted shapes which screws up the rest of the script.

So my question is - Has anyone else experienced anything like this, is it likely to be a bug in the tool, or could it be my scripting error?

0 Kudos
1 Reply
MVP Esteemed Contributor

can you confirm if you raster is an integer array since equality checks get a bit iffy if one is relying on the visual classification of the raster rather than the histogram or explicitly converting to integer using ... int ...  An of course cell size, extent and snap raster need to be explicitly set when doing these assessments.

0 Kudos