0

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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 9, 2015 at 18:16
1
  • 1
    Con( ~IsNull("A" + "B"),1) Commented Dec 9, 2015 at 19:08

1 Answer 1

2

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.

answered Dec 9, 2015 at 18:46
3
  • 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) 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 Commented Dec 11, 2015 at 20:31
  • Ooop, @Felix, sorry thst I missed your answer; it was so short and succinct! Commented Dec 11, 2015 at 20:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.