By robintw


2012-05-02 11:04:11 8 Comments

I have a raster in ArcGIS which has a number of cells with the values 9999, showing that the data could not be generated for that cell. I want to convert all of these 9999 values to NoData, so that then I can do statistics on the dataset without getting crazy results.

How should I do this?

I have tried to use the reclassify tool, just adding one reclassification from 9999 -> No Data, but it seems to change all of the other values as well. Is there a way to do a reclassification which only does the changes you specify, and leaves all other values alone?

In case it matters, my dataset is a TIFF, with floating point values in it.

3 comments

@adriasf 2019-11-07 13:01:25

I know this is a very old question and is already answered, but today I had the same problem but found the solution on my own using the reclass tool, not arcpy. Appearently when you reclass, all the values you do not include in the ranges are not touched. Be sure also to uncheck the "Change missing values to NoData".

I had a raster with values from 1 to 30 and the NoData had to become 0, so the only range I set to be changed was NoData --> 0. Not adding the rest of the values left them alone and where carried to the new raster unchanged.

Hope this helps someone with the same doubt.

@MappaGnosis 2012-05-02 11:25:17

Your approach used to work fine in old versions of Arc but not now. You can around this by adding in another value (set to be identical to the old one). One value is usually sufficient unless you have floating point values, in which case I would add the highest and lowest original values (set to be the same as their original value). The values in between USUALLY end up as per the original.

This is a hack, so always check the results afterwards!

@Aragon 2012-05-02 11:20:59

you can do this with arcpy, if you want. In this code, any input cell with a value 9999 will be set to NoData in the output raster, and the remaining cells will retain their original value.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outSetNull = SetNull("elevation", "elevation", "VALUE = 9999")
outSetNull.save("C:/sapyexamples/output/outsetnull")

you can read Conditional evaluation with Con and Set Null (Spatial Analyst) from ArcGIS Resource Center...

Syntax
SetNull (in_conditional_raster, in_false_raster_or_constant, {where_clause})

SetNull

i hope it helps you...

@MappaGnosis 2012-05-02 12:38:18

If you have Spatial Analyst then you could also use the Set Null tool - so, just what Aragon said but not bother with the scripting part :)

@robintw 2012-05-02 12:44:12

Using your link to Set Null (Spatial Analyst) I found that I could just run that without needing to use ArcPy. I've written a How To on my blog: blog.rtwilson.com/…

@Aragon 2012-05-02 13:31:27

yes this is another way. it is good to hear solving your problem.

Related Questions

Sponsored Content

1 Answered Questions

1 Answered Questions

2 Answered Questions

[SOLVED] Reclassifying floating point raster in ArcGIS Desktop?

1 Answered Questions

1 Answered Questions

[SOLVED] Arcpy reclassify all values to same number

Sponsored Content