I'm trying to merge 4 tiles (ASC) of a French 1m digital elevation model.

Files are loaded in QGIS, they bear no errors, value range is coherent. enter image description here

Merging comes with errors and the result is a raster with 0 values. The error message is the following:

Traceback (most recent call last): File "C:\OSGeo4W\apps\Python39\Scripts\gdal_merge.py", line 14, in sys.exit(main(sys.argv)) File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo_utils\gdal_merge.py", line 650, in main return gdal_merge(argv) File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo_utils\gdal_merge.py", line 635, in gdal_merge fi.copy_into(t_fh, band, band, nodata, verbose) File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo_utils\gdal_merge.py", line 348, in copy_into return raster_copy( File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo_utils\gdal_merge.py", line 95, in raster_copy return raster_copy_with_mask( File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo_utils\gdal_merge.py", line 192, in raster_copy_with_mask t_band.WriteArray(to_write, t_xoff, t_yoff) File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo\gdal.py", line 5329, in WriteArray return gdal_array.BandWriteArray(self, array, xoff, yoff, File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo\gdal_array.py", line 680, in BandWriteArray ret = BandRasterIONumPy(band, 1, xoff, yoff, xsize, ysize, File "C:\OSGeo4W\apps\Python39\lib\site-packages\osgeo\gdal_array.py", line 256, in BandRasterIONumPy return _gdal_array.BandRasterIONumPy(band, bWrite, xoff, yoff, xsize, ysize, psArray, buf_type, resample_alg, callback, callback_data) RuntimeError: Writing through VRTSourcedRasterBand is not supported. Le processus a renvoyé le code erreur 1

No value data is -99999. I specified this value in the nodata field but this had no effect. Saving to file or temporary file has no effect. Any idea on what is causing this issue? The process was fine on other occasion with similar tiles.

Another hint: It seems tiles do not overlap. We can see here the four corners of the four tiles, under shading mode rendering. Could this be an explanation? enter image description here

1 Answer 1


Quoting to solution to one of the similar issue: https://gis.stackexchange.com/a/74068/126926 (Quick Summary: You can't write data to a VRT. It's a "Virtual Raster", and is actually just an XML file.)

You can try to save it to some location on your PC, instead of temporary(vrt) files. It should solve the issue.

  • 1
    Hi, you may be right: there is some VRT mention in the GDAL code (that I cannot edit) when saving on a temp file. I tried many times, and finally got to save it under .tiff, no VRT mention (I did not change any other setting I believe), and it worked. Strange, I'm not sure what happened...
    – Gilles
    Feb 16 at 12:49

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.