Skip to content

Infer the pole for polar stereographic metadata without an origin latitude - #4164

Open
bhaskargurram-ai wants to merge 1 commit into
Unidata:mainfrom
bhaskargurram-ai:fix/polar-stereo-origin
Open

bhaskargurram-ai wants to merge 1 commit into
Unidata:mainfrom
bhaskargurram-ai:fix/polar-stereo-origin

Conversation

@bhaskargurram-ai

Copy link
Copy Markdown

Description Of Changes

This handles the remaining part of #1844: a polar_stereographic grid mapping with standard_parallel but no latitude_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):

>>> attrs = pyproj.CRS.from_epsg(3413).to_cf()
>>> CFProjection(attrs).to_cartopy().proj4_params['lat_0']
0.0

With no origin latitude, make_polar_stereo passed no central_latitude, so CartoPy used its default of 0. The result is an equatorial stereographic projection, along with CartoPy's warning that true_scale_latitude is 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 through cartopy_crs, but at y = -2 188 km through pyproj.

When latitude_of_projection_origin is 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:

  • polar stereographic attrs with only a standard parallel (north and south) give lat_0 = ±90
  • for CF attrs from pyproj.CRS.from_epsg(3413/3031).to_cf(), CartoPy and pyproj project a point to the same x/y

All four fail on main and pass with this change. Ruff and flake8 are clean.

Checklist

…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
bhaskargurram-ai requested a review from a team as a code owner October 18, 2026 03:57
@bhaskargurram-ai
bhaskargurram-ai requested review from dopplershift and removed request for a team October 18, 2026 03:57
@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyproj output not acceptd by metpy

2 participants