I have two DEMS. One is a 10m DEM (let's call it DEM-A) covering a large area (projection EPSG 4326). The other is a higher resolution DEM (DEM-B) that was constructed from a structure-from-motion point cloud, but has since been down-sampled to 10m and projected into the same coordinate system (EPSG 4326). I need to replace the values in DEM-A with the values in DEM-B where there are such, and keep all values of DEM-A where there there is nothing (i.e. nodata in DEM-B or no coverage of DEM-B).

In the image below, you can see parts of DEM-A on the right, and parts of DEM-B on the left. Black cells are nodata (-9999). You can see that the grids don't quite match, so DEM-B will need to be resampled to fit the grid in DEM-A.

I feel like this should be a straigthforward conditional statement, but I can't get it to work. Happy to get suggestions for QGIS, gdal, or anything open source.

  • What have you tried so far? You tagged gdal in your question. This seems like the perfect job for something like gdal_merge. – Kersten Oct 15 '17 at 8:09
  • I tried merge in QGIS which crashes with a mysterious error about format [Format driver GMT does not support creation and piecewise writing. Please select a format that does, such as GTiff (the default) or HFA (Erdas Imagine)], and I've tried to run gdalwarp demA demB mosaic, which replaces the corresponding values of demB in demA, but unfortunately keeps the nodata values (-9999) in the output file (i.e. around the are covered by demA). – Mylène Jacquemart Oct 17 '17 at 5:48
  • Have you tried the nodata options of gdal_merge, -n and -a_nodata? – Kersten Oct 17 '17 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.