Add regional templates to from_template (Africa, Asia, the Americas, Oceania)#3553
Conversation
Add southeast_asia (EPSG:10594), central_america/caribbean (EPSG:10598), and west_africa (EPSG:10592), each in its GLANCE continental Lambert azimuthal equal-area projection. Real EPSG codes keep attrs['crs'] an int. Reuses the existing region dispatch, so all four backends work.
brendancol
left a comment
There was a problem hiding this comment.
PR Review: Add regional templates to from_template
Blockers (must fix before merge)
None.
Suggestions (should fix, not blocking)
xrspatial/_template_data.py: the fourboundstuples are hand-maintained numbers, each one thelonlatbox projected into its GLANCE CRS. I recomputed them and they match to sub-metre, so they are right today, but nothing stops a future edit or regeneration from drifting the two apart, and a wrong bounds value silently misgeoreferences the grid. A registry-integrity test (like the cities have) that reprojects each region'slonlatand checks it against the storedboundswithin a tolerance would catch that.
Nits (optional improvements)
xrspatial/_template_data.py: none of the four regions setshape_epsg, sofrom_template(name, preserve='shape')falls back to the centroid's UTM zone, which only covers a slice of a continental extent. That is the expected EPSG-clean fallback (there is no EPSG conformal continental code, unlike Europe's curated LCC 3034), but a one-line comment would save the next reader a double-take.xrspatial/_template_data.py: thesoutheast_asiabox reaches lat -11 andcentral_americareaches lat 7, each roughly 0.2 to 1 degree past the southern edge of its GLANCE projection's official area of use. LAEA still projects those points finitely (verified), so the grid is valid, just slightly outside the projection's nominal extent.
What looks good
- Real EPSG codes throughout (GLANCE 10592/10594/10598), so
attrs['crs']stays an int, matching the convention and theeuropeLAEA precedent. - Pure data addition: the new names are plain
_REGIONSentries that ride the existing region dispatch, so all four backends and thepreservepath work with no logic change. - Tests cover the contract, bounds containment, case-insensitive lookup, and the LAEA CF grid-mapping for each region;
test_registry_codes_resolveandtest_list_templates_groupedpick the new regions up on their own. - Stored bounds verified against the reprojected lonlat boxes to sub-metre.
Checklist
- Algorithm matches reference (EPSG codes and projected bounds verified with pyproj)
- All implemented backends produce consistent results (shared region dispatch)
- NaN handling correct (NaN-filled, asserted)
- Edge cases covered (case-insensitive, bounds containment)
- Dask chunk boundaries handled (lazy da.full, no overlap)
- No premature materialization
- Benchmark not needed (no compute kernel)
- Docstrings updated (name list extended)
- README left as-is (open-ended row already covers the new regions; avoids a conflict with #3550)
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review (after commit 4bca7b9)
All three items from the first pass are handled.
- Suggestion (bounds drift): added
test_regional_bounds_match_reprojected_lonlat, which reprojects each region'slonlatand asserts it matches the storedboundswithin 2 m. A future edit that desyncs the two now fails the test instead of shipping a misgeoreferenced grid. - Nit (shape_epsg fallback): documented in the
_REGIONScomment that these regions intentionally omitshape_epsg, sopreserve='shape'falls back to the centroid UTM zone. - Nit (area-of-use overshoot): no code change. The lon/lat boxes follow the real region extent (e.g. Timor at -11, Panama at 7), and LAEA projects those points finitely; the comment now records this.
No new findings. Tests: 87 passed locally (numpy, cupy, dask backends).
# Conflicts: # docs/source/reference/templates.rst # xrspatial/templates.py # xrspatial/tests/test_templates.py
Add north_africa/east_africa/southern_africa (GLANCE Africa 10592), south_asia/east_asia/central_asia/middle_east (GLANCE Asia 10594), south_america (GLANCE S. America 10603), and oceania (GLANCE Oceania 10601). Same EPSG-coded continental LAEA pattern as the first batch; covered by the existing parametrized regional tests.
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review (after commit 8335d54): additional regions
Added nine more regions at the same level, each on its GLANCE continental LAEA EPSG code:
- Africa (10592):
north_africa,east_africa,southern_africa - Asia (10594):
south_asia,east_asia,central_asia,middle_east - South America (10603):
south_america - Oceania (10601):
oceania
Each lon/lat box was reprojected into its GLANCE CRS to derive the stored bounds, and the test_regional_bounds_match_reprojected_lonlat check confirms they match to within 2 m. oceania is bounded west of the antimeridian (110-179E: Australia, New Guinea, New Zealand) so the box does not wrap 180. The existing parametrized regional tests cover all of them through the extended _REGIONAL list.
No new findings. Tests: 147 passed locally (numpy, cupy, dask backends).
Add Europe subregions (western/eastern/northern/southern_europe, GLANCE Europe 10596), central_africa, north_asia, greenland, South America subregions (amazon_basin/andes/southern_cone), australia, new_zealand, and antarctica (Antarctic Polar Stereographic 3031, with area_epsg=6932 S-polar LAEA for preserve='area'). Every continent now has a few regions.
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review (after commit 05cf9fa): full continent coverage
Filled out every continent:
- Europe (GLANCE Europe 10596):
western_europe,eastern_europe,northern_europe,southern_europe - South America (10603):
amazon_basin,andes,southern_cone - Africa (10592):
central_africa - Asia (10594):
north_asia - North America (10598):
greenland - Oceania (10601):
australia,new_zealand - Antarctica (3031):
antarctica
Antarctica is the one non-GLANCE region: it uses Antarctic Polar Stereographic (the standard there), which is conformal, so area_epsg points at the south-polar LAEA EPSG:6932 and preserve='area' returns a real equal-area code rather than mislabeling 3031. It has dedicated tests (test_antarctica_contract, test_antarctica_grid_mapping_and_preserve); the GLANCE regions stay covered by the parametrized _REGIONAL suite, including the bounds-integrity check.
No new findings. Tests: 209 passed locally (numpy, cupy, dask backends).
Add canada, mexico, great_lakes, pacific_northwest, gulf_coast, new_england, great_plains, and american_southwest, all in GLANCE North America LAEA (EPSG:10598). Covered by the parametrized regional tests.
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review (after commit bbab5ec): more North America regions
Added the common North America gaps, all on GLANCE North America (EPSG:10598):
canada,mexico— the two missing neighbors of the existing CONUS/Alaskagreat_lakes— cross-border, common in hydrologypacific_northwest,gulf_coast,new_england,great_plains,american_southwest— standard US macro-regions
All ride the parametrized _REGIONAL suite (contract, bounds containment, case-insensitive, bounds-match-reprojected-lonlat within 2 m, GLANCE grid-mapping). North America now has 11 curated regions.
No new findings. Tests: 249 passed locally (numpy, cupy, dask backends).
Add 'pacific' (alias 'pdc') global template in EPSG:3832 (WGS 84 / PDC Mercator), the Pacific Disaster Center projection centered on lon_0=150 so the Pacific Ocean is continuous (map seam in the Atlantic). Conformal, so preserve='area' falls back to Equal Earth.
brendancol
left a comment
There was a problem hiding this comment.
Follow-up review (after commit a66d19e): Pacific-centered template
Added pacific (alias pdc): the Pacific Disaster Center projection, EPSG:3832 (WGS 84 / PDC Mercator). It is a Mercator with lon_0=150, so the Pacific Ocean is drawn continuously and the map seam falls in the Atlantic (~30 W). Native bounds are the full longitude extent (x = +/-a*pi = +/-20037508 m) and the ellipsoidal Mercator y at the conventional +/-85.0511287798 latitude limit.
A real EPSG code, so attrs['crs'] stays an int (and 3832 has a CF grid_mapping_name='mercator', unlike 3857). It is conformal, so area_epsg points at Equal Earth (8857) for preserve='area'. Covered by test_global_projection_contract/test_global_projection_case_insensitive and a dedicated test_pacific_pdc_mercator (grid mapping, PDC WKT, pdc alias identity, preserve fallback).
No new findings. Tests: 253 passed locally (numpy, cupy, dask backends).
Closes #3552
Adds curated continental and subcontinental regions to
from_template, covering every continent. Each is in an EPSG-coded GLANCE continental Lambert azimuthal equal-area projection (the equal-area analog of the existingeuropeLAEA region), except Antarctica, which uses the de-facto standard Antarctic Polar Stereographic.attrs['crs']stays a real EPSG int throughout.central_america,caribbean,greenland,canada,mexico,great_lakes,pacific_northwest,gulf_coast,new_england,great_plains,american_southwestsouth_america,amazon_basin,andes,southern_conewestern_europe,eastern_europe,northern_europe,southern_europewest_africa,north_africa,east_africa,southern_africa,central_africasoutheast_asia,south_asia,east_asia,central_asia,middle_east,north_asiaoceania,australia,new_zealandantarctica— conformal, sopreserve='area'returns the south-polar LAEA (EPSG:6932) instead of claiming 3031 is equal-areaThe new names are plain
_REGIONSentries, so they ride the existing region dispatch with no logic change; numpy, cupy, dask+numpy, and dask+cupy all work, and the dask path stays lazy.Note: the original request spelled it
carribean; the template uses the correctcaribbean.Test plan
pytest xrspatial/tests/test_templates.py(249 passed, including the cupy and dask backends that run on this box)polar_stereographic;preserve='area'-> 6932,preserve='shape'-> 3031)