I am trying to mosaic 792 DEM of 1m resolution using this tutorial (https://automating-gis-processes.github.io/CSC18/lessons/L6/raster-mosaic.html), however it results in a large file (27.9GB) and I get this error "MemoryError: Unable to allocate 27.9 GiB for an array with shape (1, 170000, 44000) and data type float32". I understand that this error is due to overcommit issue but how can I reduce the size of output image initially so that I wont face issue in further analysis like MrVBF etc.
1 Answer
You should use GDAL's virtual raster format to create one virtual raster, the Virtual Raster (VRT) will then reference each of your 792 rasters individually without duplicating data or making one large file.
You can do this in QGIS. Go to Raster Menu > Miscellaneous > Virtual Raster
Then click three dots to add individual rasters:
Select Add Files/Add directory here to add files (not sure how it will react to 729 rasters though). Choose remaining options and then run.
-
I am new to python so can you please tell me if this the right command or I should add more variables too. Thanks vrt = gdal.BuildVRT("merged_dem.vrt", demlist) gdal.Translate("merged_dem.tif", vrt) vrt = None Commented May 9, 2021 at 7:02
-
-
-
1
-
1@user182365 accept the answer if it solves your issue. Thanks. Commented May 10, 2021 at 16:53
gdalbuildvrt
. That may be the easiest way to preserve resolution. Not sure how your software will cope later, however.