Opened 14 years ago

Closed 3 years ago

#1808 closed defect (wontfix)

NetCDF Driver Improvements

Reported by: warmerdam Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: netcdf
Cc: Mateusz Łoskot, dnadeau, PCJ, Kyle Shannon

Description (last modified by warmerdam)

Paavo Jumppanen (CSIRO) has prepared substantial improvements to the netcdf driver. He recently updated them and writes:

I've looked at and integrated my changes into the gdal-1.4.2 code and
now a a working development version. My modified driver behaves as the
unmodified one when used in the normal way. My interpretation XML I have
ditched in place of arguments passed in the filename in a manner in the
same spirit of the original driver. I did so to be consistent with the
spirit of GDAL and to not lead to confusion as there appears to be other
XML stuff in the library that I'm not familiar with. The changed files
I've attached to this email.

The functionality of the new driver is much the same as my old variant
except in the way it is specified. This is summarised in my comment
block for the netCDFInterpretation class:
//
------------------------------------------------------------------------
-----
// class netCDFInterpretation

//
------------------------------------------------------------------------
-----
// The purpose of this class is to extract and collate explicit meta
data
// from the string passed to GDAL when requesting to open the file. This

// extra meta data allows users to customise the way in which the netCDF
// driver interprets the data within the specified netCDF file. The 
// following key value pairs can be appended to the open string to
change
// driver behaviour:
//
// units=<units value>
// coordinates=<lon name>,<lat name>
// extent=<left value>,<top value>,<right value>,<bottom value>
// range=<min value>,<max value>
// scaling=<scale value>(,<offset value>)
// hue=<start hue value>(,<end hue value>)
// lightness=<start lightness value>,(<end lightness value>)
// saturation=<start saturation value>,(<end saturation value>)
// bands=<N>
// band<1>=<var name 1>,<var value 1>,<var name 2>,<var value 2>...
// band<2>=<var name 1>,<var value 1>,<var name 2>,<var value 2>...
//  .
//  .
//  .
//
// As an example, we might have this in a Mapserver layer definition:
//
// DATA
NETCDF:"SSTcomp3d_Aasia_1995.nc":sst:coordinates=lon,lat:range=5,30:unit
s="degrees
C":hue=240,0:lightness=128,156:saturation=255:scaling=0.16,15:bands=1:ba
nd1=time,11768
//
// This tells the driver which variables to use for longitude and
latitude,
// the range to display (values outside the range are transparent), the 
// units of the data, the HLS colour map to use to colourise the data,
// the scaling to apply to the raw data, the number of bands to create,
// and how to select that band. In the last instance, the band<N> entry
// is used to specify the missing coordinate values for the band in
cases
// where the number of coordinates in the array data is greater than
two.
// To be able to use the colour map you msut also specify a range for
the 
// mapping to be applied to.
//
------------------------------------------------------------------------
-----

Basically, if you open with,

DATA NETCDF:"SSTcomp3d_Aasia_1995.nc":sst

It works the old way. If you add any extra parameters then it does it
the new way based on what you've specified. If you wish to include it in
the code base I would be delighted. If you don't I'll live with that and
just maintain the extensions I need privately. 

Attachments (4)

update.tar.gz (27.1 KB) - added by warmerdam 14 years ago.
updated changes
nc_driver_update.tar.gz (27.1 KB) - added by PCJ 14 years ago.
Changed ReadAndMapBlock?() method to use nc_get_vara_schar instead of nc_get_vara_uchar. NC_BYTE data is internally signed so treating it as unsigned created imaging problems for NC_BYTE data.
nc_driver_update_rev3.tar.gz (27.2 KB) - added by PCJ 14 years ago.
Some 4d files have single values in one d. The old code assumed more than one value per d. Changed netCDFMap constructor to support this case.
nc_drvier_update_rev4.tar.gz (27.2 KB) - added by PCJ 14 years ago.
Change line 160 of netcdfdataset.cpp as old version assumes co-ordinate values increase with co-ord index, which may not be the case.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 14 years ago by warmerdam

Description: modified (diff)

Trim out unrelated flipping issue.

Denis, would you be in a position to review and apply the driver changes? If not, I can turn it over to Mateusz though he has little experience with the esoteric world of netcdf as far as I know.

comment:2 Changed 14 years ago by PCJ

Cc: Mateusz Łoskot dnadeau PCJ added; mloskot dnadeau removed

comment:3 Changed 14 years ago by PCJ

Changed 14 years ago by warmerdam

Attachment: update.tar.gz added

updated changes

comment:4 Changed 14 years ago by warmerdam

Paul writes:

"Good news. The issue with the flipping I needed is no longer an issue and must have been resolved somewhere along the line. As such I've pulled the Flip code out and also needed to make some minor changes to fix some typos. I've attached my latest code to this email. I tried putting it directly into the ticket but it told me I needed TICKET_ADMIN privileges. Can you replace it please."

I have replaced update.tar.gz with his new version. Paul - I think the ticket admin was just required because you were not the ticket submitter and you were replacing an existing attachment. In the future you could add it with a new name.

Changed 14 years ago by PCJ

Attachment: nc_driver_update.tar.gz added

Changed ReadAndMapBlock?() method to use nc_get_vara_schar instead of nc_get_vara_uchar. NC_BYTE data is internally signed so treating it as unsigned created imaging problems for NC_BYTE data.

Changed 14 years ago by PCJ

Some 4d files have single values in one d. The old code assumed more than one value per d. Changed netCDFMap constructor to support this case.

Changed 14 years ago by PCJ

Change line 160 of netcdfdataset.cpp as old version assumes co-ordinate values increase with co-ord index, which may not be the case.

comment:5 Changed 14 years ago by warmerdam

Milestone: 1.5.01.5.1

comment:6 Changed 12 years ago by Kyle Shannon

Cc: Kyle Shannon added

comment:7 Changed 7 years ago by Jukka Rahkonen

Have these enhancements ever been applied to NetCDF driver?

comment:8 Changed 6 years ago by Even Rouault

Milestone: 1.8.1

Removing obsolete milestone

comment:9 Changed 3 years ago by Even Rouault

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub?. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.