Select to view content in your preferred language

multiply two rasters but ignore no data values from first raster

2750
4
04-21-2010 10:48 AM
JoannaWhittier
Regular Contributor
Attached is a pdf depicting what I need to do with 2 raster layers.  This has to be an easy task but I can't find a tool that won't combine all the no data cells in the output raster.  For example, if a cell in raster 1 is 'no data' and the associated cell in raster 2 has a value of '8', I want that cell in the output file to be 8.  All the tools I looked at would assign that cell as 'no data'.
0 Kudos
4 Replies
CedricWannaz
Emerging Contributor
Another, less elegant, method to obtain the output of the conditional statement above would be to reclassify NoData values to 0 in your two rasters. The tool is in Spatial Analyst Tools/Reclass/Reclassify.

In both cases the output will not be the one that you provide I guess, in the sense that you will have 0 values instead of the NoData that you show in your PDF, but you should be able to output NoData values when both inputs are NoData by building another structure of conditional statement.

Cheers,

Cedric
0 Kudos
JoannaWhittier
Regular Contributor
Thank you!
0 Kudos
GaryYoung
Occasional Contributor
Con( IsNull( [Raster1] ), 0, [Raster1] ) + Con( IsNull( [Raster2] ), 0, [Raster2] )

will do it.


Where do I use that conditional statement?  I do not do python.

The reclassify suggestion offered will not work for me, as it will not preserve the unique values of all the other cells, it will lump them into a small set of new values.

Gary
0 Kudos
ArfanaraNajnin
New Contributor
For multiplication is that command OK, Or it's for adding two raster?
Con( IsNull( [Raster1] ), 0, [Raster1] ) + Con( IsNull( [Raster2] ), 0, [Raster2] )

For Multiply we should use the * (multiplication) Symbol as normal math, isn't it?
So the expression may be this one if I am not wrong.
  'Con( IsNull( [Raster1] ), 0, [Raster1] ) * Con( IsNull( [Raster2] ), 0, [Raster2] )'

Regrads,

Najnin
0 Kudos