Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Re: GDAL netcdf convention CF support


Hi Denis,

I'd also done a "bit" of work on this, but I'll happily abandon my efforts if your driver is now in the distribution.

I had a look at your code (haven't compiled it yet) but one thing I had in my driver that you might like to consider adding is a check to see if the file is CF compliant (or rather, a check to see if it has the CF "Conventions" attribute).

Also, if I remember rightly (it's been a few months since I wrote it) this check should stop your netCDF driver picking up "GMT" grid files, which should be left to the GMT driver to deal with.

This is the check I added, with a bit of the existing code for reference:

/* -------------------------------------------------------------------- */
/*      Try opening the dataset.                                        */
/* -------------------------------------------------------------------- */
   int cdfid, dim_count, var_count;

   if( nc_open( poOpenInfo->pszFilename, NC_NOWRITE, &cdfid ) != NC_NOERR )
       return NULL;

/* ----------------------------------------------------------------------- */
   /*This bit added by Dominic Lowe, British Atmospheric Data Centre.*/
   /*Checking for CF (Climate & Forecast) compliance:
   First check for Conventions global attribute*/
/* ----------------------------------------------------------------------- */
       attname = (char *) malloc(NC_MAX_NAME*sizeof(char));
if ((status = nc_get_att_text(cdfid, NC_GLOBAL, "Conventions", attname)) != NC_NOERR)
   {
CPLError( CE_Warning, CPLE_AppDefined, "No Conventions global attribute");*/
        /* note that 'Conventions' is always capital 'C' in CF spec*/
       return NULL;
       nc_close( cdfid );
   }

   /*then check Conventions is of the form "CF-etc" eg "CF-1.0"*/
     if( attname[0] != 'C'
       || attname[1] != 'F'
       || attname[2] != '-'  )
   {
CPLError( CE_Warning, CPLE_AppDefined, "Convention attribute did not match CF convention");
       return NULL;
       nc_close( cdfid );
    }
/* ----------------------------------------------------------------------- */
Hope that's useful, I'll give the driver a go sometime soon.

Dominic



Denis Nadeau wrote:

GDAL now supports netcdf format using CF convention as specified by unidata.

   http://www.unidata.ucar.edu/software/netcdf/conventions.hdf

The software looks if the variables lat/latitude and lon/longitude are presents in the netcdf file. If found, these variables are used to specify the georeferencing transformation.

I'd like the community to try it out and if there are some problems, let me know. GDAL netcdf format also works on Windows with he precompile library version 3.6.1-beta1 (January 2005).

Regards,
Denis Nadeau



 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690