Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netCDF: Implement full read/write support for new NetCDF4 types NC_UB… #99

Closed
wants to merge 2 commits into from
Closed

netCDF: Implement full read/write support for new NetCDF4 types NC_UB… #99

wants to merge 2 commits into from

Conversation

jdemaria
Copy link
Contributor

…YTE, NC_USHORT, NC_UINT and NC_STRING for variables (except for NC_STRING) and attributes.

Only available if NETCDF_HAS_NC4 is defined and only if format=NC4 for writing.
NC_STRING type is supported for reading (scalar and arrays) attributes and is used for writing only for array attributes (scalar are still written as NC_CHAR).
If NETCDF_HAS_NC4 is not defined or format!=NC4, NC_STRING array attributes are written as a single NC_CHAR string using the GDAL {v1,v2,...} convention.

…YTE, NC_USHORT, NC_UINT and NC_STRING for variables (except for NC_STRING) and attributes.

Only available if NETCDF_HAS_NC4 is defined and only if format=NC4 for writing.
NC_STRING type is supported for reading (scalar and arrays) attributes and is used for writing only for array attributes (scalar are still written as NC_CHAR).
If NETCDF_HAS_NC4 is not defined or format!=NC4, NC_STRING array attributes are written as a single NC_CHAR string using the GDAL {v1,v2,...} convention.
@jdemaria
Copy link
Contributor Author

I checked that this does not break autotests netcdf.py and netcdf_cf.py

@jdemaria
Copy link
Contributor Author

Concerning the NC_STRING type, I have seen that a new creation option for vector has been added:
<Option name='USE_STRING_IN_NC4' type='boolean' description='Whether to use NetCDF string type for strings in NC4 format. If NO, bidimensional char variable are used' default='YES'/>
Maybe this option could be shared with the raster driver (impacting only attributes) because user may want create NC_STRING or NC_CHAR? so the option could be moved from layer creation options to dataset ones? I don't know if then we should modify all nc_put_att_text() in the raster and vector drivers to be able to switch to nc_put_att_string()... but I think CF still does not support NC_STRING(?)
(http://mailman.cgd.ucar.edu/pipermail/cf-metadata/2014/057153.html)
For the moment I use NC_STRING for writing only for array attributes (scalar are still written as NC_CHAR).

kwrobot pushed a commit to aashish24/gdal-svn that referenced this pull request Feb 28, 2016
…USHORT, NC_UINT and NC_STRING for variables (except for NC_STRING) and attributes (patch by Julien Demaria, OSGeo/gdal#99)

Only available if NETCDF_HAS_NC4 is defined and only if format=NC4 for writing.
NC_STRING type is supported for reading (scalar and arrays) attributes and is used for writing only for array attributes (scalar are still written as NC_CHAR).
If NETCDF_HAS_NC4 is not defined or format!=NC4, NC_STRING array attributes are written as a single NC_CHAR string using the GDAL {v1,v2,...} convention.



git-svn-id: https://svn.osgeo.org/gdal/trunk/gdal@33586 f0d54148-0727-0410-94bb-9a71ac55c965
@rouault
Copy link
Member

rouault commented Feb 28, 2016

Committed in r33586.

Regarding USE_STRING_IN_NC4 moved as dataset creation options, this is your call. I've added this capability for layer vectors so as to avoid the auto-grow logic of OGR string fields of non-bounded size, which is costly both in file size and speed. But admitedly probably a bit borderline regarding CF.

@rouault rouault closed this Feb 28, 2016
@floriandeboissieu
Copy link

At the moment, when band names are specified as NC_STRING, GDALGetMetadata is returning an empty value in front of NETCDF_DIM_xxx = although the corresponding values are well decoded:

Metadata:
  NETCDF_DIM_band_DEF={10,12}
  NETCDF_DIM_band_VALUES={B2,B3,B4,B5,B6,B7,B8,B8A,B11,B12}
  NETCDF_DIM_EXTRA={band}
Band 1 Block=10980x1 Type=Int16, ColorInterp=Undefined
  NoData Value=-32767
  Metadata:
    add_offset=0
    coordinates=spatial_ref time
    grid_mapping=spatial_ref
    NETCDF_DIM_band=
    NETCDF_VARNAME=bands
    scale_factor=1

Would it be possible to include NC_STRING support within band metadata (i.e. case NC_STRING in CreateBandMetadata I suppose)?
It would be very useful to have such a support for SENTINEL 2 (example above), and would propagate to its support in QGIS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants