pyproj4/pyproj

Add support for building coordinate system with from_cf/to_cf

Closed this issue · 6 comments

Since WKT (or PROJ JSON) is the backend for the CF conversions, additional support for different units and axis order are now possible. Currently the x/y axis order and units of meters for projected degrees for geographic are assumed.

http://cfconventions.org/cf-conventions/cf-conventions.html#coordinate-system

Examples of input units can be accessed from the coordinates:
http://cfconventions.org/cf-conventions/cf-conventions.html#coordinate-types

  double y(y);
    y:units = "km";
    y:long_name = "y coordinate of projection";
    y:standard_name = "projection_y_coordinate";
  double x(x);
    x:units = "km";
    x:long_name = "x coordinate of projection";
    x:standard_name = "projection_x_coordinate";
  double lat(y, x);
    lat:units = "degrees_north";
    lat:long_name = "latitude coordinate";
    lat:standard_name = "latitude";
  double lon(y, x);
    lon:units = "degrees_east";
    lon:long_name = "longitude coordinate";
    lon:standard_name = "longitude";

Additionally, the vertical component can be supported:
http://cfconventions.org/cf-conventions/cf-conventions.html#vertical-coordinate

axis_name:units = "meters" ;
axis_name:positive = "down" ;
Horizontal dimensions are those whose coordinate variables have an axis attribute of X or Y, or a units attribute indicating latitude and longitude.

Axis example:

{'units': 'rad',
 'axis': 'X',
 'long_name': 'GOES Projection x-Coordinate',
 'standard_name': 'projection_x_coordinate'}

This looks useful: https://github.com/SciTools/cf-units

Using: m.convert(1, "m") on any unit should get the unit conversion factor.

Not going to include in pyproj as it adds unnecessary dependencies for a piece of functionality that is not really a main PROJ feature. Instead, I am leaning towards documentation for how to do it yourself if you so desire.

Also, here is the file/database for the unit name mappings:

More specifically:

Can do fraction of unit - this can be used for unit conversion factor:

>>> from cf_units import Unit
>>> u = Unit("0.5 m")
>>> u.convert(1, "m")
0.5