New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building Compound CRS with WGS84 & EGM96? #630
Comments
>>> import pyproj
>>> geoid = pyproj.CRS.from_epsg(5773)
>>> geoid
<Vertical CRS: EPSG:5773>
Name: EGM96 height
Axis Info [vertical]:
- H[up]: Gravity-related height (metre)
Area of Use:
- name: World
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: EGM96 geoid
- Ellipsoid: undefined
- Prime Meridian: undefined So, you need to build the CRS you want: https://pyproj4.github.io/pyproj/stable/build_crs.html >>> from pyproj.crs import CompoundCRS
>>> cmpd_crs = CompoundCRS(name="WGS 84 + EGM96 height", components=["EPSG:4326", "EPSG:5773"])
>>> cmpd_crs
<Compound CRS: {"$schema": "https://proj.org/schemas/v0.2/projjso ...>
Name: WGS GeoID
Axis Info [ellipsoidal|vertical]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
- H[up]: Gravity-related height (metre)
Area of Use:
- undefined
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
Sub CRS:
- WGS 84
- EGM96 height
>>> pyproj.CRS(4979)
<Geographic 3D CRS: EPSG:4979>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
- h[up]: Ellipsoidal height (metre)
Area of Use:
- name: World (by country)
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich With that, your axis order should be consistent. >>> trans = pyproj.Transformer.from_crs(cmpd_crs, "EPSG:4979")
>>> trans.transform(45, -122, 10)
(45.0, -122.0, 10.0) |
@snowman2 thanks a lot for taking the time to write this detailed answer! As a CRS-newbie everything PROJ-related can be a bit overwhelming... Out of interest, is it expected that EDIT: There seems to be a small typo in the very last line of your answer. I think it should read: (45.0, -122.0, -10.386833190917958) instead of (45.0, -122.0, 10.0) |
It does some auto-conversions behind the scenes. But, with limited information it may or may not produce what you want. Probably where the axis-order inconsistencies come into play.
Probably due to my environment missing the needed grid. |
Side note, here is the shorthand version for the compound CRS: >>> cc = CRS("EPSG:4326+5773")
>>> cc
<Compound CRS: EPSG:4326+5773>
Name: WGS 84 + EGM96 height
Axis Info [ellipsoidal|vertical]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
- H[up]: Gravity-related height (metre)
Area of Use:
- undefined
Datum: World Geodetic System 1984
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
Sub CRS:
- WGS 84
- EGM96 height |
Thanks! As far as I'm concerned the issue is resolved so feel free to close it |
It seems this has stopped working in the update to version 3. Running the above code prints |
Disclaimer: I have read https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6 and am aware of the fact that PROJ now honors the axis order of a CRS when initialized with
EPSG:xxxx
.Code Sample
I think I have found an inconsistency in the way the axis order is interpreted with
EPSG:4326
.Consider the following snippet:
It prints the following output:
Problem description
Since the axis order of
EPSG:4326
isI would expect to always have to pass
x=lat, y=lon
in aTransformer.transform
call in order for everything to work correctly.However as shown with the snippet above:
x=lon, y=lat
that gives the correct outputx=lat, y=lon
that gives the correct output.Expected Output
I would expect to always have to pass
x=lat, y=lon
inTransformer.transform
when mycrs_from
isEPSG:4326
, irrespective of what mycrs_to
is.Environment Information
2.6.1.post1
Installation method
pip wheel
The text was updated successfully, but these errors were encountered: