[gdal-dev] Creating NetCDF dataset with sub datasets

Even Rouault even.rouault at spatialys.com
Thu Mar 7 06:08:07 PST 2024


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 at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list