Repository navigation
Infer the pole for polar stereographic metadata without an origin latitude - #4164
Open
bhaskargurram-ai wants to merge 1 commit into
Open
bhaskargurram-ai wants to merge 1 commit into
bhaskargurram-ai wants to merge 1 commit into
Conversation
…itude CF metadata for polar stereographic projections that only gives the standard parallel (as pyproj's CRS.to_cf() does for EPSG:3413, EPSG:3031 and other variant B CRSs) has no latitude_of_projection_origin. The CartoPy CRS then got CartoPy's default central latitude of 0, i.e. an equatorial stereographic projection, while the pyproj CRS was correct. Take the pole from the hemisphere of the standard parallel in that case, as PROJ does. Fixes Unidata#1844
bhaskargurram-ai
requested review from
dopplershift
and removed request for
a team
October 18, 2026 03:57
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description Of Changes
This handles the remaining part of #1844: a
polar_stereographicgrid mapping withstandard_parallelbut nolatitude_of_projection_origin. pyproj still writes CF metadata like this for "Polar Stereographic (variant B)" CRSs (pyproj 3.8.0; see pyproj4/pyproj#856), so it shows up for common grids such as EPSG:3413 (NSIDC north) and EPSG:3031 (Antarctic):With no origin latitude,
make_polar_stereopassed nocentral_latitude, so CartoPy used its default of 0. The result is an equatorial stereographic projection, along with CartoPy's warning thattrue_scale_latitudeis only used for polar projections.to_pyproj()on the same metadata was correct. For EPSG:3413, the point (45°W, 70°N) comes out at y = +8 911 km throughcartopy_crs, but at y = -2 188 km through pyproj.When
latitude_of_projection_originis missing and a standard parallel is given, the pole is now taken from the hemisphere of the standard parallel (+90 or -90). PROJ handles variant B the same way. Metadata that already has the origin latitude behaves as before.Tests in
tests/plots/test_mapping.py:lat_0= ±90pyproj.CRS.from_epsg(3413/3031).to_cf(), CartoPy and pyproj project a point to the same x/yAll four fail on main and pass with this change. Ruff and flake8 are clean.
Checklist