I'm using gdal_merge.py to merge a few GeoTIFF's into a GeoPackage. The source files are UTM33 projection, 3 bands (RGB) without Nodata tags. They make up a non-rectangular mosaic, so gdal_merge correctly sets alpha=0 on the areas without data in the resulting GeoPackage.

However, it also inexplicably fills in a bit of black border. I notice that the black borders only appear along the "internal borders" i.e., not around the outer bounding box of the GeoPackage. Does anyone know if and how this can be fixed?

Note: I know that other GDAL tools such as GDALWarp is probably better for this particular case, but I am using this as a test for processes with very large amounts of source data. In such cases, gdal_merge is the best option I've found.

Command used:

gdal_merge -of GPKG -o output.gpkg srcfile1.tif srcfile2.tif srcfile3.tif srcfile4.tif

Source files: enter image description here

Resulting GeoPackage: enter image description here

  • For anyone with the same issue, I think I got to the bottom of this. Gdal_merge does not actually set alpha=0 anywhere. The large, empty area in the northeast does simply not contain any tiles at all. When gdal_merge creates a tile which is not fully covered by the source data it will (incorrectly I should say) fill it out with black (0, 0, 0, 255). So, in conclusion, this seems to be a limitation with gdal_merge when merging datasets which does not make up a full rectangle. – Matsamentet Apr 24 at 8:48

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.