I have two contiguous raster files that I would like to include in a single GeoPackage file. The two rasters report to the same CRS:
$ gdalinfo T001.tif
Driver: GTiff/GeoTIFF
Files: T001.tif
Size is 480, 480
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (4.999970400000010,50.999172485999999)
Pixel Size = (0.002083333000000,-0.002083333000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=DEFLATE
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 4.9999704, 50.9991725) ( 4d59'59.89"E, 50d59'57.02"N)
Lower Left ( 4.9999704, 49.9991726) ( 4d59'59.89"E, 49d59'57.02"N)
Upper Right ( 5.9999702, 50.9991725) ( 5d59'59.89"E, 50d59'57.02"N)
Lower Right ( 5.9999702, 49.9991726) ( 5d59'59.89"E, 49d59'57.02"N)
Center ( 5.4999703, 50.4991726) ( 5d29'59.89"E, 50d29'57.02"N)
Band 1 Block=480x8 Type=Int16, ColorInterp=Gray
NoData Value=-32768
$ gdalinfo T002.tif
Driver: GTiff/GeoTIFF
Files: T002.tif
Size is 480, 480
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (5.999970240000025,50.999172485999999)
Pixel Size = (0.002083333000000,-0.002083333000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
COMPRESSION=DEFLATE
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 5.9999702, 50.9991725) ( 5d59'59.89"E, 50d59'57.02"N)
Lower Left ( 5.9999702, 49.9991726) ( 5d59'59.89"E, 49d59'57.02"N)
Upper Right ( 6.9999701, 50.9991725) ( 6d59'59.89"E, 50d59'57.02"N)
Lower Right ( 6.9999701, 49.9991726) ( 6d59'59.89"E, 49d59'57.02"N)
Center ( 6.4999702, 50.4991726) ( 6d29'59.89"E, 50d29'57.02"N)
Band 1 Block=480x8 Type=Int16, ColorInterp=Gray
NoData Value=-32768
I start by creating a new GeoPackage from the first raster, and things seem to go as expected:
$ gdal_translate -of GPKG T001.tif tiles.gpkg
Input file size is 480, 480
0...10...20...30...40...50...60...70...80...90...100 - done.
$ gdalinfo tiles.gpkg
Driver: GPKG/GeoPackage
Files: tiles.gpkg
Size is 480, 480
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
Origin = (4.999970400000010,50.999172485999999)
Pixel Size = (0.002083333000000,-0.002083333000000)
Metadata:
AREA_OR_POINT=Area
IDENTIFIER=tiles
ZOOM_LEVEL=1
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 4.9999704, 50.9991725) ( 4d59'59.89"E, 50d59'57.02"N)
Lower Left ( 4.9999704, 49.9991726) ( 4d59'59.89"E, 49d59'57.02"N)
Upper Right ( 5.9999702, 50.9991725) ( 5d59'59.89"E, 50d59'57.02"N)
Lower Right ( 5.9999702, 49.9991726) ( 5d59'59.89"E, 49d59'57.02"N)
Center ( 5.4999703, 50.4991726) ( 5d29'59.89"E, 50d29'57.02"N)
Band 1 Block=256x256 Type=Int16, ColorInterp=Undefined
Min=4.000 Max=245.000
NoData Value=-32768
Metadata:
STATISTICS_MAXIMUM=245
STATISTICS_MINIMUM=4
However, once I add the second raster the CRS information is automatically reset to null:
$ gdal_translate -of GPKG T002.tif tiles.gpkg -co APPEND_SUBDATASET=YES
Input file size is 480, 480
0...10...20...30...40...50...60...70...80...90...100 - done.
$ gdalinfo tiles.gpkg
Driver: GPKG/GeoPackage
Files: tiles.gpkg
Size is 512, 512
Coordinate System is `'
Subdatasets:
SUBDATASET_1_NAME=GPKG:tiles.gpkg:tiles
SUBDATASET_1_DESC=tiles - tiles
SUBDATASET_2_NAME=GPKG:tiles.gpkg:T002
SUBDATASET_2_DESC=T002 - T002
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 512.0)
Upper Right ( 512.0, 0.0)
Lower Right ( 512.0, 512.0)
Center ( 256.0, 256.0)
This means, for instance, that importing this GeoPackage to GRASS fails.
How can I add the CRS information to the tiled GeoPackage? Is there a specific parameter for it in gdal_translate
? Or should I use another command à posteriori?