0

I'm used to using PROJ strings/dictionaries in python where I have access to a proj_dict['proj'] element. I have some calculations that I can only do with the PROJ.4 geos projection and otherwise fallback to a naive calculation. Since PROJ strings are not the preferred way of accessing this information anymore I'm wondering how I could do this same check with a pyproj CRS object.

Here's my example:

from pyproj import CRS
proj_dict = {'a': '6378137.0', 'b': '6356752.31414', 'h': '35786023.0', 'lon_0': '-89.5', 'proj': 'geos', 'sweep': 'x', 'units': 'm'} 
c = CRS.from_dict(proj_dict)

The only thing I see related to "geos" is the coordinate operation method:

<Projected CRS: +proj=geos +a=6378137.0 +b=6356752.31414 +h=357860 ...>
Name: unknown
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- undefined
Coordinate Operation:
- name: unknown
- method: Geostationary Satellite (Sweep X)
Datum: unknown
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

Is that the same thing as PROJ's proj parameter?

1

You are on the right track. However, it isn't exactly the same as the proj parameter. There are some differences. But, for your purposes of checking if it is the geos projection, the coordinate operation should provide what you need.

>>> from pyproj import CRS
>>> geos_dict = {'a': '6378137.0', 'b': '6356752.31414', 'h': '35786023.0', 'lon_0': '-89.5', 'proj': 'geos', 'sweep': 'x', 'units': 'm'}
>> CRS(geos_dict).coordinate_operation.method_name
'Geostationary Satellite (Sweep X)'
>>> geos_dict_y = {'a': '6378137.0', 'b': '6356752.31414', 'h': '35786023.0', 'lon_0': '-89.5', 'proj': 'geos', 'sweep': 'y', 'units': 'm'}
>>> CRS(geos_dict_y).coordinate_operation.method_name
'Geostationary Satellite (Sweep Y)'

However, I would caution that the coordinate operation does not always exist. So, I would check for that:

>>> CRS("+proj=latlon").coordinate_operation
>>> CRS("+proj=latlon")
<Geographic 2D CRS: +proj=latlon +type=crs>
Name: unknown
Axis Info [ellipsoidal]:
- lon[east]: Longitude (degree)
- lat[north]: Latitude (degree)
Area of Use:
- undefined
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
  • So the property always exists (no AttributeError) but it may be None, right? – djhoese Dec 3 '19 at 13:41
  • 1
    Yeah, that is correct. The coordinate_operation will always exist. – snowman2 Dec 3 '19 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.