Thursday, 16 August 2018

Reclassify raster values of 9999 to NoData, leaving all other values alone, in ArcGIS Desktop?


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.




Answer



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...


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...