question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`geographic_crs_name` missing from the CF version of a CRS

See original GitHub issue

Code Sample, a copy-pastable example if possible

from pyproj import CRS                                                                                                                
crs = CRS.from_proj4('+proj=omerc +alpha=8.998112717187938 +lat_0=0.0 +lonc=13.809602948622212 +gamma=0 +ellps=sphere')               
print(crs.to_cf())                                                                                                                           

Problem description

When using the latest cfchecker (4.0.0) on a netcdf file containing the output of crs.to_cf, we get an error:

------------------
Checking variable: oblique_mercator
------------------
INFO: (5.6): CF checker currently does not verify the syntax of the crs_wkt attribute which must conform to the CRS WKT specification
ERROR: (5.6): reference_ellipsoid_name, prime_meridian_name, horizontal_datum_name and geographic_crs_name must all be definied if any one is defined

Indeed, the output from to_cf in this case is:

{'crs_wkt': 'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["Unknown based on Normal Sphere (r=6370997) ellipsoid",ELLIPSOID["Normal Sphere (r=6370997)",6370997,0,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Hotine Oblique Mercator (variant B)",ID["EPSG",9815]],PARAMETER["Latitude of projection centre",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8811]],PARAMETER["Longitude of projection centre",13.8096029486222,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8812]],PARAMETER["Azimuth of initial line",8.99811271718794,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8813]],PARAMETER["Angle from Rectified to Skew Grid",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8814]],PARAMETER["Scale factor on initial line",1,SCALEUNIT["unity",1],ID["EPSG",8815]],PARAMETER["Easting at projection centre",0,LENGTHUNIT["metre",1],ID["EPSG",8816]],PARAMETER["Northing at projection centre",0,LENGTHUNIT["metre",1],ID["EPSG",8817]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]',
 'semi_major_axis': 6370997.0,
 'semi_minor_axis': 6370997.0,
 'inverse_flattening': 0.0,
 'reference_ellipsoid_name': 'Normal Sphere (r=6370997)',
 'longitude_of_prime_meridian': 0.0,
 'prime_meridian_name': 'Greenwich',
 'horizontal_datum_name': 'Unknown based on Normal Sphere (r=6370997) ellipsoid',
 'grid_mapping_name': 'oblique_mercator',
 'latitude_of_projection_origin': 0.0,
 'longitude_of_projection_origin': 13.809602948622212,
 'azimuth_of_central_line': 8.998112717187938,
 'scale_factor_at_projection_origin': 1.0,
 'false_easting': 0.0,
 'false_northing': 0.0}

As you can see, geographic_crs_name is missing. As the CF document says:

Corresponds to a OGC WKT GEOGCS node name

and I don’t see one in the wkt attached.

So in conclusion, with this projection definition, it looks like to me that the to_cf method isn’t generating a CF compliant grid mapping.

Expected Output

I would expect geographic_crs_name to be present in the keys of the returned dict.

Environment Information

pyproj info: pyproj: 2.6.0 PROJ: 6.3.1 data dir: /home/a001673/miniconda3/envs/py3/lib/python3.8/site-packages/pyproj/proj_dir/share/proj

System: python: 3.8.2 | packaged by conda-forge | (default, Mar 23 2020, 18:16:37) [GCC 7.3.0] executable: /home/a001673/miniconda3/envs/py3/bin/python machine: Linux-4.18.0-147.5.1.el8_1.x86_64-x86_64-with-glibc2.10

Python deps: pip: 20.0.2 setuptools: 46.1.3.post20200325 Cython: 0.29.14

Installation method

  • conda

Conda environment information (if you installed with conda):


Environment (conda list):
$ conda list | grep -E "proj|aenum"
proj                      6.3.1                hc80f0dc_1    conda-forge
pyproj                    2.6.0            py38h95a477d_0    conda-forge


Details about conda and system ( conda info ):
$ conda info
     active environment : py3
    active env location : /home/a001673/miniconda3/envs/py3
            shell level : 2
       user config file : /home/a001673/.condarc
 populated config files : /home/a001673/.condarc
          conda version : 4.8.3
    conda-build version : not installed
         python version : 3.7.4.final.0
       virtual packages : __glibc=2.28
       base environment : /home/a001673/miniconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/a001673/miniconda3/pkgs
                          /home/a001673/.conda/pkgs
       envs directories : /home/a001673/miniconda3/envs
                          /home/a001673/.conda/envs
               platform : linux-64
             user-agent : conda/4.8.3 requests/2.23.0 CPython/3.7.4 Linux/4.18.0-147.5.1.el8_1.x86_64 rhel/8.1 glibc/2.28
                UID:GID : 62310:2000
             netrc file : None
           offline mode : False


Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mraspaudcommented, Mar 31, 2020

I’ll bake a small PR soon then, thanks !

0reactions
snowman2commented, Mar 31, 2020

That sounds like a good plan to me. Also, asking for clarification here: https://github.com/cf-convention/cf-conventions/issues/255

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add missing CF parameters to translate Coordinate Reference ...
Adding new parameters to the CF grid_mapping specification would allow to translate projected and geographic CRS WKT definitions to/from CF grid_mapping ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found