Ticket #1660 (closed enhancement: duplicate)

Opened 7 years ago

Last modified 3 years ago

add support for scale and offset in netCDF driver.

Reported by: hulst Owned by: dnadeau
Priority: normal Milestone: 1.8.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords: netcdf, scale offset, add_offset, scale_factor
Cc: hulst@…, kyle

Description

Hello,

I've modified the netcdf driver so that it supports scale and offset attributes.

 http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.0/cf-conventions.html#attribute-appendix

One can argue from the description above that the netcdf driver is not responsible for applying offset and scale, but the calling application. I find the driver a convenient location.

Attached you find the updated driver. For now I can think of one situation where the driver gives problems:

--- In order to apply scale and offset the data is read in the native netCDF type (f.i. UInt16), but stored as a float in memory. I maintain the original _FillValue of the originating dataset (e.g., -32768). When the dataset contains this value after the application of scale and offset the data is wrongfully accused of being garbage. A small chance, but still. ---

Regards, Sander

Attachments

netcdfdataset.cpp Download (102.7 KB) - added by hulst 7 years ago.
netcdf-scale-offset-support-mloskot.patch Download (150.0 KB) - added by mloskot 6 years ago.
This is regular patch including fixes proposed in attached netcdfdataset.cpp file.

Change History

Changed 7 years ago by hulst

Changed 7 years ago by hulst

  • version changed from 1.4.1 to svn-trunk
  • component changed from default to GDAL_Raster
  • milestone set to 1.5.0

Changed 7 years ago by warmerdam

Sander,

Note that GDALRasterBand has methods to get the offset and scale. The normal GDAL practice would be to return them via those methods - not to apply them on the fly. Then it is up to the caller to do so if they wish.

Changed 7 years ago by hulst

Hi Frank,

I'm aware of that. I have implemented the GetOffset? etc for netCDF. Indeed I apply them on the fly if I encounter such an attribute.

I agree with you that this is not the way it is normally done (only on request), but I failed to see how I should make such a request. Especially from mapserver that is.

Note that I need to take a real good look at the driver as there's an issue with int8 data, but I'll sort that out.

Changed 6 years ago by warmerdam

  • owner changed from Denis Nadeau to dnadeau

Changed 6 years ago by mloskot

This is regular patch including fixes proposed in attached netcdfdataset.cpp file.

Changed 6 years ago by mloskot

Unfortunately, using attached netcdfdataset.cpp file to generate regular patch with svn diff output big patch being a mixture of real fixes and fake fixes like mixed tabs/spaces, etc.

I'd suggest and be very thankful for submitting real patches generated on user's system shortly after fixes have been applied, instead of submitting just a changed file. Patches are easy to review and apply, big files of mess are almost impossible to apply.

Changed 4 years ago by kyle

  • cc kyle added

Changed 4 years ago by kyle

  • keywords netcdf, offset, add_offset, added; netcdf offset add_offset removed

Changed 3 years ago by kyle

  • status changed from new to closed
  • resolution set to duplicate
  • milestone changed from 1.5.4 to 1.8.0

changing this to a duplicate of #3797 , as it has a test dataset. I will take a look at the patch as well.

Note: See TracTickets for help on using tickets.