4

I'm trying to get the difference between two raster layers the same way we can do it with the difference tool with vector layers. I'm using QGIS 2.14.

Anyone has already done that and can tell me how to proceed ?

0

4 Answers 4

4
  1. Use Polygonize on one raster (Raster > Conversion > Polygonize (Raster to Vector))
  2. Create a new polygon shapefile which covers the entire extent of the main raster you want differenced
  3. Use the Difference tool on the new polygon shapefile and the polygonized shapefile
  4. Use Clipper and select the input raster (in which you want to get the difference) and use the differenced shapefile as the mask layer (Raster > Extraction > Clipper)
0
2

Well depends a bit on what you want to do... When you say Difference it is usually meant to calculate Rasters cells (for example substract the values from each other), then the Raster Calculator ist what you want as Sethinacan mentioned.

I guess you mean Clip by a mask layer. Therfore it is easier to just draw the Square around the area you want to clip into a new file an use this as the mask in the Clipper tool. You can also use the advaced digitizing tools to put into the exact extend values...

I definitly would not use Polygonize, as it will try to make Polygons out of areas with the same color value. You will probably end up with thousands of objects an a long processing time.

2
  • Clip with a mask layer does the inverse of what I want to do, that's why I'm not using it. I want to remove the parts of the 1st raster layer and not extract the parts of my raster layer that are within the second layer...
    – kaycee
    Mar 18, 2016 at 16:33
  • I see, misunderstood that part... The way Joseph mentioned is then the way you can go. But still i would not use Polygonize just to get the extend of the difference raster, as it might take long, but however it works of course
    – Matte
    Mar 18, 2016 at 17:14
0

You can clip by mask layer, but make the mask the opposite of what you want to delete. See the attached picture. Notice the 'corridor.' Which is so narrow it won't even appear in the clipped tif.enter image description here

1
  • As the main quest @Joseph wanted to know how to substract raster from raster, and not polygon from raster.
    – Vaiaro
    Mar 8, 2023 at 13:30
0

For QGIS 3:

Refering to @Josephs answer, substitute the Polygonize tool with the Extract layer extent (native:polygonfromlayerextent) tool for increased performance. With that tool just the extent of the raster layer will be exported as an polygon.

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.