I’d like to load a subdataset from a TIF file into my PostGIS Database.
gdalinfo gives me the following infos about the TIF-file:
Driver: GTiff/GeoTIFF
Files: pathto/imagename.tif
Size is 611, 1
Coordinate System is `'
Metadata:
TIFFTAG_IMAGEDESCRIPTION=CXmlTiff type
TIFFTAG_RESOLUSTIONUNIT=2 (pixels/inch)
TIFFTAG_XRESOLUTION=100
TIFFTAG_YRESOLUTION=100
ImageStructure Metadata:
INTERLEAVE=BAND
Subdatasets:
SUBDATASET_1_NAME=GTIFF_DIR:1:pathto/imagename.tif
SUBDATASET_1_DESC=Page 1 (611P x 1L x 1B)
SUBDATASET_2_NAME=GTIFF_DIR:2:pathto/imagename.tif
SUBDATASET_2_DESC=Page 1 (392P x 514352L x 1B)
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 1.0)
Upper Right ( 611.0, 0.0)
Lower Right ( 611.0, 1.0)
Center ( 305.5, 0.5)
Band 1 Block=611x1 Type=Byte, ColorInterp=Gray
I’d like to load the second subdataset (392×514352).
Right now, using raster2pgsql and the filename as input, only the first subdataset is loaded, the second one is ignored. There is only one band, so using the -b switch does not work. Any advice?
Thanks a lot
Thomas
Subdatasets are not common in rasters, and I’ve never seen them in TIFFs (normally, you see bands, not subdatasets). It looks like a similar bug was fixed for HDF5 files, but this probably won’t help your GTiff. I’d encourage you to create a bug ticket for this feature.
In the meantime, gdal_translate could be used with the
-sdsoption to copy all subdatasets of your file to individual output files, which you could then use with raster2pgsql.