[gdal-dev] Passing open options along dataset name in a string ?

Even Rouault even.rouault at spatialys.com
Tue Nov 17 03:21:03 PST 2020


> The variation of subdataset syntax among drivers is a bug, let's try to fix
> this.
> 
> It seems to me that the internet way to address subdatasets would be to use
> a # URL fragment. But since most of our formats and the servers that serve
> files of these formats are not aware, we may have to come up with something
> different. We may need to consider making subdatasets a layer opening
> option?

Hum, I'm a bit confused. Isn't the purpose to have a single string covering 
subdataset specification and open options ?

Because you could potentially have use cases where you open a "container" 
dataset with its name and open options (not selecting a particular subdataset) 
and the GetMetadata("SUBDATASETS") should return potentially a GDN that would 
have the same open options but also additions foreach specific subdataset.

Let's say "gdalinfo my.hdf5 -oo FOO=BAR" would return a list of subdatasets:
gdn:HDF5:my.hdf5+encoding_FOO=BAR+encoding_VARIABLE=temperature
gdn:HDF5:my.hdf5+encoding_FOO=BAR+encoding_VARIABLE=pressure


Some additions to Jukka's answer:

> > gdalinfo GTIFF_DIR:0:d:\my.tif
> 
> WTF is this? :)

https://gdal.org/drivers/raster/gtiff.html :
"""
Multi-page TIFF files are exposed as subdatasets. On opening, a subdataset 
name is GTIFF_DIR:{index}:filename.tif, where {index} starts at 1.
"""
(ok, so my example was wrong :-) should have benn GTIFF_DIR:1:d:\my.tif)

> 
> > gdalinfo EEDAI:my/asset
> > gdalinfo EEDAI: -oo ASSET=my/asset
> > gdalinfo EEDAI:my/asset:band1, band2
> > gdalinfo EEDAI: -oo ASSET=my/asset -oo BANDS=band1,band2
> 
> Never seen these.

Cf https://gdal.org/drivers/raster/eedai.html

This driver shows a case where we handle both worlds. The specification of a 
dataset can be in the dataset name ("EEDAI:my/asset") or as a dataset name 
("EEDAI:") + open options (ASSET=my/asset). This was my attempt to use open 
options as a way of having more explictness on how to specify the subparts of 
a subdataset, but perhaps this wasn't a good idea. But this is a case where 
the border between what is the dataset/subdataset name and what is an open 
option is fuzzy. "gdalinfo EEDAI:" without any option will not work: you can't 
reasonably list all datasets hosted on Earth Engine...

But in some circumstances (when all bands don’t have the same georeferencing, 
resolution, CRS or image dimensions), whatever you open with  dataset name 
("EEDAI:my/asset") or as a dataset name ("EEDAI:") + open options (ASSET=my/
asset), you may get a list of subdatasets

> > GDALOpen() is not even aware that HDF5:bla means that the dataset will be
> > recognized by the HDF5 driver
> 
> Wait what?

GDALOpen() just iterates over drivers and passes the dataset name and open 
options to them until one says "yes, that's for me". The use of 
"DRIVER_NAME:bla" is mostly a convention, but in no way a core mechanism. If 
you use DRIVER_NAME:bla fo a driver that doesn't recognize the DRIVER_NAME: 
prefix, that won't work.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list