1

I am working with QGIS 3.16.0 and I have a raster layer (A) consisting of 2 values: 1 is where there are olive tree, 0 is where there are no olive trees: enter image description here

I have the second raster (B) classified the same just for a smaller area: enter image description here

I need the areas of the first raster non overlapped by the second raster, so I applied raster calculator : (A) - (B), however, I did not got the difference of these two rasters, I got this result: enter image description here

Which is the same as the raster I subtracted and not the difference of the two layers.

What am I missing here?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Paris
  • 591
  • 3
  • 17
  • 1
    I think you should be looking for some kind of Clip function. Raster calculator is going to subtract pixel values from one another, so if rasters A and B are based on the same classification, then A-B is either going to be 1-1 or 0-0 for every cell, which will give you that result raster full of 0s. – ycartwhelen Feb 16 '21 at 15:33
  • Thanks @ycartwhelen, the problem is I do not have a vector layer of the second raster that I can extract the first raster from it. I tried polygonize the second raster but there are so many small poygons that working overnight could not convert all these rasters to shapefiles. That is why I am after a second solution – Paris Feb 16 '21 at 15:40
  • 1
    Try reclassifying your original layer to have non-olives be something other than 0 (2 for the purposes of this discussion), and then multiplying this layer by the all zeros results layer in Raster Calculator. That should result in a layer with 1 (olives), 2 (non-olives), and 0 (area of Raster B to be ignored). Take a look at MappaGnosis' answer here: https://gis.stackexchange.com/questions/86960/clipping-raster-layer-with-raster-mask-layer-in-qgis – ycartwhelen Feb 16 '21 at 17:17

0 Answers0