Select to view content in your preferred language

Change raster values?

2969
1
Jump to solution
09-22-2013 11:06 AM
RachelAlbritton
Frequent Contributor
I have several raster's in which I need to change a group of values to 0, and I need to keep all other values the same. I know that I could use the reclassify tool, but its not practical in this instance where the list of the remaining values in very long and using the reclassify tool would require ALL values in the raster to be recoded. I'm wondering if maybe there's a conditional statement I could construct in the raster calculator?
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Rachel,

You can do this using the Con tool as you suspected.  Here is an example on how to iterate through rasters in a directory and change all values less than 1 in each raster to a value of 0:

import arcpy from arcpy import env env.workspace = r"C:\temp\python"  arcpy.CheckOutExtension("spatial")  for raster in arcpy.ListRasters("*"):     arcpy.gp.Con_sa(raster, "0", raster + "_con.tif", raster, '"VALUE" < 1')

View solution in original post

0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
Hi Rachel,

You can do this using the Con tool as you suspected.  Here is an example on how to iterate through rasters in a directory and change all values less than 1 in each raster to a value of 0:

import arcpy from arcpy import env env.workspace = r"C:\temp\python"  arcpy.CheckOutExtension("spatial")  for raster in arcpy.ListRasters("*"):     arcpy.gp.Con_sa(raster, "0", raster + "_con.tif", raster, '"VALUE" < 1')
0 Kudos