How to convert null values to 0 in raster calculator?

7372
5
12-27-2011 09:40 PM
ferranferrer
New Contributor
Hi,
I'm trying to convert null values to zero or other values in raster calculator.

Help say this but i don't understand
'1. Identify the NoData locations:
    Input raster = 'inRaster1'
    Output raster = 'outNullMap'

2. Perform Con on the results to give the original NoData areas a value:
    Input conditional raster = 'outNullMap'
    Input true raster or constant value = '100'
    Input false raster or constant value = 'inRaster1'
    Output raster = 'null100_final'
    Expression = 'Value = 1'

Thanks for your attention, ferran
0 Kudos
5 Replies
Robert_LeClair
Esri Notable Contributor
Hi Ferran -

Instead of the raster calculator, I would use the CON geoprocessing tool in the Spatial Analyst toolbox.  The syntax for the GP tool would be as follows:

in_conditional_raster = your input raster
in_true_raster_or_constant = 0
in_false_raster_or_constant = your input raster
where_clause = VALUE IS NULL

If the raster cell evaluates as TRUE (i.e. IS NULL), the cell gets a value of 0.  Else if the raster cells evaluates FALSE (i.e. IS NOT NULL), then the raster cell gets the original input raster cell value.

Good luck!

Robert LeClair
Esri-Denver
0 Kudos
clintonchiavarini
New Contributor
This doesn't seem to work for me.  the "VALUE IS NULL" returns no records.  The only way I've found to do this successsfully is by the method described here using two GP tools (CON and IS NULL):

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000ms000000.htm

It would be really nice if there was a way to do this with a single command...

Hi Ferran -

Instead of the raster calculator, I would use the CON geoprocessing tool in the Spatial Analyst toolbox.  The syntax for the GP tool would be as follows:

in_conditional_raster = your input raster
in_true_raster_or_constant = 0
in_false_raster_or_constant = your input raster
where_clause = VALUE IS NULL

If the raster cell evaluates as TRUE (i.e. IS NULL), the cell gets a value of 0.  Else if the raster cells evaluates FALSE (i.e. IS NOT NULL), then the raster cell gets the original input raster cell value.

Good luck!

Robert LeClair
Esri-Denver
0 Kudos
GayathriAlallasundaram
New Contributor III
Hi,

You may also use the Reclassify tool to do this,

1. ArcToolbox > Spatial Analyst > Reclass > Reclassify
2. Select Input raster.
3. Make sure all your valid old values are the same in new values.
4. Change old nodata value to 0
5. Save the output raster.

Also here is a link to the tech article which discusses about the same operation using the CON and IsNULL.

http://resources.arcgis.com/content/kbase?fa=articleShow&d=34932


Regards,
Gayu
0 Kudos
Robert_LeClair
Esri Notable Contributor
The workflow IsNull and Con functionality outlined here:  http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000ms000000.htm could be combined in ModelBuilder and run as a single process.  The user would set the necessary parameters for input to apply to different input raster datasets.  Just a thought...

Regards,

Robert LeClair
Esri-Denver
0 Kudos
ferranferrer
New Contributor
Thanks a lot!!!
I've resolved this with

etpm01x = ASCIIGRID (etpm01.txt , FLOAT)
etpm01 = CON(ISNULL (etpm01x) , 0.001, etpm01x )
in raster calculator, the code i ran is four A4 long, for that i was looking for this kind of solution.
thanks, ferran
0 Kudos