Using Arc 10.2.2 with Spatial Analyst, I need to determine the spatial intersection of two rasters (both rasters are in the same coordinate system, and are aligned to the same snap raster). The two rasters have different values.

Specifically, I want to determine which cells are occupied by both raster A and raster B.

Here's my method, using the Raster Calculator:

  1. I create an intermediate raster each for raster A and B, calculating the output to the value 1. This identifies, for each raster, which cells are occupied:

intermediate_A = (A * 0) + 1

intermediate_B = (B * 0) + 1

  1. Add the two intermediate rasters together:

final_output = intermediate_A + intermediate_B

The final_output raster will have the value 2 for the intersecting cells, otherwise NoData.

Everything seems to work correctly. However, I'm wondering if there's a more efficient way to determine the spatial intersection with fewer steps or without creating the intermediate rasters?

  • 1
    Con( ~IsNull("A" + "B"),1)
    – FelixIP
    Commented Dec 9, 2015 at 19:08

1 Answer 1


Try: Con(((IsNull(A))|(IsNull(B))),0,1)

If either A or B are null it will give you 0 if not 1, all the ones should show where A and B have values.

  • 1
    Excellent! After a little investigation, I confirmed that additional rasters can be easily tested by simply extending your equation. For example, to determine those cells where three rasters (A, B, C) intersect: Con(((IsNull(A))|(IsNull(B))|(IsNull(C))),0,1)
    – Stu Smith
    Commented Dec 10, 2015 at 21:38
  • great! @FelixIP's code is even shorter and does the same thing. I always forget to use the '~'. He took advantage of the fact that any operation with a nodata cell will always become nodata, so even if, only one raster has no data at that location when you add it with another that has value, it just becomes 'nodata'. A great alternative workaround
    – yanes
    Commented Dec 11, 2015 at 20:31
  • Ooop, @Felix, sorry thst I missed your answer; it was so short and succinct!
    – Stu Smith
    Commented Dec 11, 2015 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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