gdalbuildvrt basin.vrt basin_h16v02.tif basin_h16v03.tif
gdal_translate -co COMPRESS=DEFLATE -co ZLEVEL=9 basin.vrt basin.tif
ogrmerge.py -single -progress -skipfailures -overwrite_ds -f GPKG -o basin.gpkg basin_h16v02.gpkg basin_h16v03.gpkg
rm -f basin_dissolved.gpkg
ogr2ogr -nlt POLYGON -dialect sqlite -sql "SELECT ST_Union(ST_MakeValid(geom)),"ID" FROM merged GROUP BY "ID" " basin_dissolved.gpkg basin.gpkg