⇐ ⇒

[CF-metadata] Question on WKT representation of CRS

From: Etienne Tourigny <etourigny.dev>
Date: Tue, 22 Nov 2011 15:34:14 -0200

Hi Jonathan.

you are correct about the additions that would be needed to support
these files.

About GDAL, recent changes to the netcdf driver (by Pat Sunter and I)
have made it fully (I hope) CF-1.5 compliant, with some issues in
certain projections. This is in the dev version, though. The stable
version does a decent job in most cases.

The new version supports both import and export of netcdf-CF files. A
recent gdal utility (gdalrsinfo, dev version) takes an input file or
CRS, and prints a number of GDAL's supported projection definitions
(WKT, proj4, etc).
I guess all that is missing is generating a CF definition in cdl
format for consulting. Anyway, if you take an input file with WKT
(say a geotiff file), and translate it to netcdf format, the result is
a netcdf CF file.
(gdal_translate -of file.tif file.nc ).

What we added recently was better lon/lat support, better projection
support (still some glitches in some cases) and also export of lon/lat
values for a projected grid (optional).

More info here:
http://trac.osgeo.org/gdal/wiki/NetCDF_Improvements
http://trac.osgeo.org/gdal/wiki/NetCDF_ProjectionTestingStatus


Here is an example of import of a CF file (LCC) to WKT
 $ ncdump -h orog_MM5I.nc
netcdf orog_MM5I {
dimensions:
        xc = 123 ;
        yc = 99 ;
variables:
[...]
        char Lambert_Conformal ;
                Lambert_Conformal:grid_mapping_name = "lambert_conformal_conic" ;
                Lambert_Conformal:standard_parallel = 30., 60. ;
                Lambert_Conformal:longitude_of_central_meridian = -97. ;
                Lambert_Conformal:latitude_of_projection_origin = 47.5 ;
                Lambert_Conformal:false_easting = 3825000. ;
                Lambert_Conformal:false_northing = 3200000. ;
[...]

$ gdalinfo NETCDF:/data/research/work/gdal-netcdf/narrcap/orog_MM5I.nc:orog
Driver: netCDF/Network Common Data Format
Files: none associated
Size is 123, 99
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9108"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",30],
    PARAMETER["standard_parallel_2",60],
    PARAMETER["latitude_of_origin",47.5],
    PARAMETER["central_meridian",-97],
    PARAMETER["false_easting",3825000],
    PARAMETER["false_northing",3200000]]
Origin = (775000.000000000000000,5725000.000000000000000)
Pixel Size = (50000.000000000000000,-50000.000000000000000)

and round-trip conversion back to netcdf:
$ gdal_translate -of gtiff -q NETCDF:orog_MM5I.nc:orog tmp1.tif
$ gdal_translate -of netcdf -co WRITE_GDAL_TAGS=NO -q tmp1.tif tmp1.nc
$ ncdump -h tmp1.nc
netcdf tmp1 {
dimensions:
        x = 123 ;
        y = 99 ;
variables:
        char lambert_conformal_conic ;
                lambert_conformal_conic:grid_mapping_name = "lambert_conformal_conic" ;
                lambert_conformal_conic:longitude_of_prime_meridian = 0. ;
                lambert_conformal_conic:semi_major_axis = 6378137. ;
                lambert_conformal_conic:inverse_flattening = 298.257223563 ;
                lambert_conformal_conic:longitude_of_central_meridian = -97. ;
                lambert_conformal_conic:false_easting = 3825000. ;
                lambert_conformal_conic:false_northing = 3200000. ;
                lambert_conformal_conic:latitude_of_projection_origin = 47.5 ;
                lambert_conformal_conic:standard_parallel = 30., 60. ;
[...]

cheers
Etienne

On Tue, Nov 22, 2011 at 2:22 PM, Jonathan Gregory
<j.m.gregory at reading.ac.uk> wrote:
> Dear Etienne
>
> Thank you for your two examples. This is very helpful. In the first example,
> as you say, it appears that a new grid_mapping type of sinusoidal is needed.
> It is easy to add new grid_mappings to Appendix F if their definition is known.
> In the second example, the essential extra features are the names of the
> geographical coordinate system, datum and spheroid, the prime meridian, and the
> TOWGS84 parameters. Have I got that right? These would require new attributes
> for the grid_mapping variable in Table F.1.
>
> It is also interesting to see that GDAL's netCDF driver can convert WKT into
> CF attributes. Can it translate the other way too?
>
> Best wishes
>
> Jonathan
>
Received on Tue Nov 22 2011 - 10:34:14 GMT

This archive was generated by hypermail 2.3.0 : Tue Sep 13 2022 - 23:02:41 BST

⇐ ⇒