I have a DEM(1) of a bigger area and a higher resolution DEM(2) in a small part of the same area. I would like to cut a hole in DEM1 and replace it with DEM2.

Is there a non python way of cutting a hole from a mask in a raster layer in QGIS?


Assuming that your DEMs are both rasters, one approach would be to mosaic the two raster layers using the aptly named 'Mosaick raster layers' tool in QGIS (can be found in the 'Processing Toolbox', using the 'Advanced Interface').
The key is to choose the correct option in the dropdown menu for 'Overlapping Areas'.


You can use GDAL to do this, first assuming your two datasets are different resolutions use gdalwarp to make sure the lower resolution dataset is resampled the same as the high res layer:

gdalwarp input.vrt output.vrt -tr x_res Y_res -r CUBIC -srcnodata -9999 -dstnodata -9999 -of vrt

Then use gdalbuildvrt to combine your two datasets - ensure that you put the low resolution first and the high resolution layer second in the list:

gdalbuildvrt output.vrt low_res_resampled layer high_res_layer 

Then finally you can convert the output .vrt to a .tif using gdal_translate make sure you include the -co COMPRESS=DEFLATE to reduce the file size and -co BIGTIFF=YES if the file is likely to exceed 4gb:

gdal_translate -co COMPRESS=DEFLATE -co BIGTIFF=YES output_from_buildvrt output.tif

These tools are also available through QGIS itself: GDAL Tools

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.