I need to unify many raster tiles of global land use (856 tiles, in a total of 297 GB, single band, 8 bite unsigned integer, WGS84) in a single file, I chose geopackage because of the high dimensions.
I tried using the following steps:
building a GDAL virtual raster with all the tiles (Parameters: NOT checking the separate band option, high resolution, resempling=mode)
converting it into a geopackage by means of gdal_translate:
gdal_translate -of GPKG -co QUALITY=100 -b 1 -mask 1 -r mode -a_offset value input.vrt output.gpkg
but the output has the following errors:
- there are some pixels with a wrong value
- the output raster has 4 bands (3 with the same values and the last with NoData, 255)
I noted that in every passage there is a shift of the pixels, a sort of cell value resampling, despite mode resampling should select the value which appears most often of all the sampled points.
How it is possible to create a single file with exactly the same pixels and parameter as the input rasters?
The original raster tile:
the same tile converted to virtual raster (info on the same cell):
the final GPKG output (info on the same cell):
In the GPKG there is a wrong new cell value (for ex. 41 instead of 40) and 4 bands instead of 1.
Note that despite the partial wrong output (some wrong pixel values and presence of 4 bands instead of 1), from a dataset of 297 GB I obtained a geopackage of 10 GB for the southern hemisphere and 34 GB for the northern hemisphere!