3

I'm in a middle of a task where I have to extract the intersection between two rasters.

I need to obtain this overlapping portion of the rasters where they touch themselves. The result I expect is something like this piece in red.

screenshot

In other words, it's similar to the Intersection function on QGIS (but this only works with vectors).

Is there something like this for rasters?

1
4

As @Babel has suggested, Raster calculator is the best tool.

For your case, there is also a useful (and relatively new) Raster boolean AND tool in the Processing Toolbox > Raster analysis group.

This is a small example, E100N90 is a background SRTM topo (sea level 0 m is set to nodata) and Rectangle is a hand-drawn reddish rectangle. You will notice Raster boolean AND tool at the right-hand side is highlighted yellow.

enter image description here

Just run Raster boolean AND tool and select these two layers as input. Use one of them as the reference layer. The Output layer shows the intersecting area as 1, while non-intersecting area is given 0.

enter image description here

That's it.

You can then use this layer (commonly called Mask) to extract the intersecting area from two input layers by the Raster Calculator.

enter image description here

Multiplying the DEM (E100N90@1) with the mask (Output layer@1) (see above expression) will return the DEM for the "intersection".

enter image description here

(Likewise; "Rectangle@1" * "Output layer@1").

1
  • 1
    Kazuhito and Babel, it was simply AWESOME!!! It worked pretty fine for me. Thanks a lot you both. Feb 10 at 16:16

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.