Ráster de Postgis: cargando Tif-Subdataset

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 `'
ImageStructure Metadata:
  SUBDATASET_1_DESC=Page 1 (611P x 1L x 1B)
  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 (392x514352).

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?

Muchas gracias


preguntado el 22 de mayo de 12 a las 14:05

2 Respuestas

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.

Mientras tanto, gdal_translate could be used with the -sds option to copy all subdatasets of your file to individual output files, which you could then use with raster2pgsql.

contestado el 22 de mayo de 12 a las 20:05

Thanks, created a ticket. With gdal_translate I get a least what I want. This helps a lot! - Thomas

Whoa, less than half a day later it looks like it was fixed! - Mike T

In the case of postgis rasters, subdatasets are created by the postgis system because postgis rasters are usually tiled and each tile is represented in the table by a different line, and usually a different rid. I am not sure what happened here, but I imagine you used the outofdb option to store your raster, right?

For those using gdal_translate for exporting rasters from postgis, you may use the option "mode='2'" in your postgresql connection options: the result is a simple file that merge all the lines of your rast column.


gdal_translate PG:"host='localhost' port='5432' dbname='mydb' user='me' schema='public' password='secret' table='rastertable' where='rid BETWEEN 1 and 10' mode='2'" /path/filename.tif

Respondido 22 ago 18, 21:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.