Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a raster file with classifcation codes, and want to reclassify valid codes to 1, and all others to 'NoData'.

RMAP2 = arcpy.sa.RemapValue([[3.2, 1],
                             [4.1, 1],
                             [4.2, 1]])

LCA = arcpy.sa.Reclassify(LCA, "LCCODE_USE", RMAP2, "NODATA")

The output however only contains the values 0 and 127, with the 0 value coinciding with just one of the missing values.

Any idea what the hell is going on?

share|improve this question
1  
I wouldn't trust a "3.2" in Python to translate, bit-by-bit, to the single precision float ArcGIS actually stores in that raster. That's asking too much. At a minimum you should be reclassifying narrow ranges of values, such as (3.15,3.25)-->1, (4.05,4.15)-->1, etc. But before even trying this, you ought to test your code with a simple, small, integer raster just to make sure you have correctly interpreted the syntax. Can you at least verify for us that such a test works and gets the right result? –  whuber Oct 22 '12 at 15:25
1  
I tried it on an integer raster, and yes it worked fine, so I floating point error makes sense. won't be able to test it out till Thursday though. –  James Jenkinson Oct 23 '12 at 20:29

1 Answer 1

I think you are using the Reclass by Table (Spatial Analyst) geoprocessing tool instead of the plain Reclassify (Spatial Analyst) geoprocessing tool. The former takes a Table View containing the ranges of values to be reclassified; the latter utilizes the arcpy.sa.RemapValue Python objects to define the ranges of values to be reclassified.

So I think your code should be:

RMAP2 = arcpy.sa.RemapValue([[3.2, 1],
                             [4.1, 1],
                             [4.2, 1]])

LCA = arcpy.sa.Reclassify(LCA, "LCCODE_USE", RMAP2, "NODATA")

I can't test this for sure, since I don't have Spatial Analyst on the machine I'm using right now.

share|improve this answer
    
Crud, sorry, I meant to edit that, I had actually been using Reclassify, but started rewriting it to Reclass by table before giving up and asking here. –  James Jenkinson Oct 22 '12 at 14:42
    
So what's up above now is the actually code I was using. –  James Jenkinson Oct 22 '12 at 14:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.