I have just no clue on this problem. I want one raster to set its values to 0 or NoData based upon another raster noData or 0 values. It's like a reclassify, but between two different raster's. I have a picture here to help illustrate:

Raster Illustration

I have two raster here: one is a depth raster (the one with the reds and has a flow look to it) and the other is a velocity raster (the one with the straight breaks).

I'd like to have the Velocity raster only exist where the Depth raster exists. I think this needs to be done in raster calculator or a clip, but so far I haven't found any way to do this.


Figured this one out. It's the Spatial Analyst tool: Set Null

arcpy.SetNull_sa(DepthRaster,VelocityRaster,OutputLovation,"Value = 0")

The last variable also sets any values of 0 to null in the velocity raster. Great little tool!


You can do it easily in QGIS (I know that you use ArcGIS, but it might be useful to know where to use opensource to get the job done). There is a RasterCalc plugin for QGIS that will do exactly what you want. Instruction on installation and usage here. If you want to change values other than 0 - you would like to use RasterCalk.

Also there is default Raster calculator in QGIS (don't mess it with RasterCalc). And you may execute following expression to exchange 0 values (assuming that 0 equals to noData, 1st band of the raster used, raster-1 - noData values source, raster-2 - noData values recipient):

(raster-1@1 != 0) * raster-2@1

Here raster-1@1 != 0 creates a binary mask from the 1st band (@1) of raster-1 where 1 corresponds to non-0 values of the raster, 0 - to 0 values. This mask then is multiplied with 1st band of raster 2, so pixels corresponding to 0 will become 0 and others will remain unchanged.

  • That sounds like a good solution, but I need to keep the work in ArcGIS.
    – Cody Brown
    Aug 31 '12 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.