[GIS] Combining two raster layers with ArcGIS Raster Calculator

arcgis-desktopraster-calculatorspatial-analyst

So I am trying to join/merge two raster layers that have values of either 1 or 0. I am using the following command in in ArcGIS Raster Calculator:

Con(("urban" == 1) | ("mixed" == 1), 1, 0)

The new raster layer is missing cells from the "urban" raster layer, I have no idea why this is happening.

I have also tried the following commands with the same result:

("urban" == 1) | ("mixed" == 1)

or

removing all the cells equal to 0 in both layers and then:

"urban" + "mixed"

Best Answer

This will work for your case:

Out_Raster = SetNull((Abs(IsNull("urban")-1)+Abs(IsNull("mixed")-1))<1,(Abs(IsNull("urban")-1)+Abs(IsNull("mixed")-1)))

Here is a part by part explanation:

  • IsNull("urban") returns 0 for data values and 1 for nulls.
  • Abs(IsNull("urban")-1) will make nulls into 0 and other cells into 1 by subtracting 1 and taking absolute value.
  • (Abs(IsNull("urban")-1)+Abs(IsNull("mixed")-1)) Compiles all 1 values from both datasets.
  • I then feed this ugly expression (UGLY_EXP) into a SetNull(UGLY_EXP<1,UGLY_EXP) to set all the 0 values to null and other cells to 1.
Related Question