Ok, I can confirm that
-creating a dataset with <n> bands with the netCDF driver works
-saving the dataset will write the expected "SUBDATASETS" domain with
"SUBDATASET_<i>_NAME=NETCDF:"<file>":"<band name>"
But I can't figure out how to customize the <band name>, which is Band1,
Band2, Band3...
I tried GDALRasterBand::SetDescription(), but without success
Also, is there a reason why AddBand() is not supported by the netCDF
driver ? I expected it to be able to add bands on demand as new "netcdf
variables".
Pierre
Hi,
If your input dataset has multiple bands, each band will be written as
a separate netCDF variable, and thus read as multiple subdatasets. The
constraint is that as your input is a single raster, all bands must
share the same georeferencing.
If you want to write multiple independent variables, then you'll have
to use the GDAL multidimensional API. Cf
https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/netcdf_multidim.py
. h5py is also quite convenient
Even
Le 07/03/2024 à 09:47, Pierre Chatelier via gdal-dev a écrit :
Hello,
I just had my first encounter with a NetCDF file. GDAL opens that
flawlessly, I can identify the subdatasets and open/read them thanks
to the SUBDATASET_n_NAME, as advertised in
https://gdal.org/drivers/raster/netcdf.html
However, I am confused by the ability to create such a file with GDAL.
Let's say I have a bunch of images that I want to pack as NetCDF
through GDAL.
Should I use bands or groups to let GDAL create the sub datasets ?
Will GDAL create the metadata SUBDATASETS domain for me ?
The NetCDF file I am supposed to create should use HDF for sub
datasets. No problem for reading (I have compiled GDAL with the HDF
support and it works, I can open my sample file), but how do I tell
GDAL to *write* that ? Should I create real datasets with the GDAL
HDF driver and then gather them into a single one with GDAL NetCDF
driver ?
Can you give some hints about what I am supposed to do ?
Pierre
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev