Skip to content

Commit 05cf9fa

Browse files
committed
Cover every continent with regional templates (#3552)
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.
1 parent 8335d54 commit 05cf9fa

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

xrspatial/_template_data.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,62 @@
107107
bounds=(-2736534, -4140479, 4725674, 773877), crs=10601,
108108
default_resolution=10000, label='Oceania (GLANCE Oceania LAEA)',
109109
lonlat=(110.0, -48.0, 179.0, -8.0), area_epsg=10601),
110+
'australia': dict(
111+
bounds=(-2397336, -3314170, 2074139, 552968), crs=10601,
112+
default_resolution=5000, label='Australia (GLANCE Oceania LAEA)',
113+
lonlat=(113.0, -44.0, 154.0, -10.0), area_epsg=10601),
114+
'new_zealand': dict(
115+
bounds=(2357704, -4140479, 3965299, -2362651), crs=10601,
116+
default_resolution=2000, label='New Zealand (GLANCE Oceania LAEA)',
117+
lonlat=(166.0, -48.0, 179.0, -34.0), area_epsg=10601),
118+
'central_africa': dict(
119+
bounds=(-1335054, -2091682, 1224158, 789768), crs=10592,
120+
default_resolution=5000, label='Central Africa (GLANCE Africa LAEA)',
121+
lonlat=(8.0, -14.0, 31.0, 12.0), area_epsg=10592),
122+
'north_asia': dict(
123+
bounds=(-2829330, 333534, 4672506, 4568106), crs=10594,
124+
default_resolution=10000, label='North Asia (GLANCE Asia LAEA)',
125+
lonlat=(60.0, 48.0, 179.0, 78.0), area_epsg=10594),
126+
'greenland': dict(
127+
bounds=(307428, 1266923, 3614205, 4339302), crs=10598,
128+
default_resolution=5000, label='Greenland (GLANCE N. America LAEA)',
129+
lonlat=(-74.0, 59.0, -11.0, 84.0), area_epsg=10598),
130+
'amazon_basin': dict(
131+
bounds=(-2129139, -422334, 1795411, 2309720), crs=10603,
132+
default_resolution=5000, label='Amazon Basin (GLANCE S. America LAEA)',
133+
lonlat=(-79.0, -18.0, -44.0, 6.0), area_epsg=10603),
134+
'andes': dict(
135+
bounds=(-2350812, -4564243, -133276, 2958360), crs=10603,
136+
default_resolution=10000, label='Andes (GLANCE S. America LAEA)',
137+
lonlat=(-81.0, -56.0, -62.0, 12.0), area_epsg=10603),
138+
'southern_cone': dict(
139+
bounds=(-1697271, -4517109, 744960, -221307), crs=10603,
140+
default_resolution=5000, label='Southern Cone (GLANCE S. America LAEA)',
141+
lonlat=(-76.0, -56.0, -53.0, -17.0), area_epsg=10603),
142+
'western_europe': dict(
143+
bounds=(-2382583, -1327155, -191916, 406028), crs=10596,
144+
default_resolution=5000, label='Western Europe (GLANCE Europe LAEA)',
145+
lonlat=(-10.0, 43.0, 17.0, 55.0), area_epsg=10596),
146+
'eastern_europe': dict(
147+
bounds=(-482758, -1221647, 2340946, 916013), crs=10596,
148+
default_resolution=5000, label='Eastern Europe (GLANCE Europe LAEA)',
149+
lonlat=(14.0, 44.0, 50.0, 60.0), area_epsg=10596),
150+
'northern_europe': dict(
151+
bounds=(-1039068, -111313, 782636, 1847310), crs=10596,
152+
default_resolution=2000, label='Northern Europe (GLANCE Europe LAEA)',
153+
lonlat=(4.0, 54.0, 32.0, 71.0), area_epsg=10596),
154+
'southern_europe': dict(
155+
bounds=(-2698894, -2211793, 739758, -416605), crs=10596,
156+
default_resolution=5000, label='Southern Europe (GLANCE Europe LAEA)',
157+
lonlat=(-10.0, 35.0, 28.0, 47.0), area_epsg=10596),
158+
# Antarctica uses the de-facto standard Antarctic Polar Stereographic
159+
# (EPSG:3031, conformal), so preserve='area' falls back to the EPSG-coded
160+
# south-polar equal-area grid (EPSG:6932) rather than claiming 3031 is
161+
# equal-area. shape_epsg is 3031 itself (already conformal).
162+
'antarctica': dict(
163+
bounds=(-3333134, -3333134, 3333134, 3333134), crs=3031,
164+
default_resolution=10000, label='Antarctica (Polar Stereographic)',
165+
lonlat=(-180.0, -90.0, 180.0, -60.0), area_epsg=6932, shape_epsg=3031),
110166
# The default (non-preserve) world grid spans the full +/-90 in EPSG:4326.
111167
# The preserve path uses a +/-85 latitude band (the conventional Web
112168
# Mercator limit) so 'shape' (World Mercator) does not diverge at the poles.

xrspatial/tests/test_templates.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ def test_global_resolution_honored_exactly():
219219
("middle_east", 10594),
220220
("south_america", 10603),
221221
("oceania", 10601),
222+
("australia", 10601),
223+
("new_zealand", 10601),
224+
("central_africa", 10592),
225+
("north_asia", 10594),
226+
("greenland", 10598),
227+
("amazon_basin", 10603),
228+
("andes", 10603),
229+
("southern_cone", 10603),
230+
("western_europe", 10596),
231+
("eastern_europe", 10596),
232+
("northern_europe", 10596),
233+
("southern_europe", 10596),
222234
]
223235

224236

@@ -238,6 +250,22 @@ def test_regional_template_contract(name, crs):
238250
assert agg.x.values[0] < agg.x.values[-1]
239251

240252

253+
def test_antarctica_contract():
254+
# Antarctica is the one region that is not GLANCE LAEA: it uses the de-facto
255+
# standard Antarctic Polar Stereographic (EPSG:3031), a projected metre CRS.
256+
agg = from_template("antarctica")
257+
assert agg.attrs["crs"] == 3031
258+
assert agg.dims == ("y", "x")
259+
assert agg.shape[0] > 1 and agg.shape[1] > 1
260+
assert np.isnan(agg.values).all()
261+
assert agg.dtype == np.float32
262+
assert agg.name == "antarctica"
263+
assert agg.x.attrs["units"] == "m"
264+
assert agg.x.attrs["standard_name"] == "projection_x_coordinate"
265+
assert agg.y.values[0] > agg.y.values[-1]
266+
assert agg.x.values[0] < agg.x.values[-1]
267+
268+
241269
@pytest.mark.parametrize("name,crs", _REGIONAL)
242270
def test_regional_template_centers_within_bounds(name, crs):
243271
agg = from_template(name)
@@ -682,6 +710,18 @@ def test_regional_template_grid_mapping(name, crs):
682710
assert _proj(crs) == "laea"
683711

684712

713+
def test_antarctica_grid_mapping_and_preserve():
714+
# Antarctic Polar Stereographic is conformal, so grid_mapping_name is
715+
# 'polar_stereographic' and preserve='area' must hand back a real equal-area
716+
# code (the south-polar LAEA EPSG:6932), not 3031.
717+
agg = from_template("antarctica")
718+
assert agg.attrs["grid_mapping_name"] == "polar_stereographic"
719+
assert _proj(3031) == "stere"
720+
assert from_template("antarctica", preserve="area").attrs["crs"] == 6932
721+
assert _proj(6932) == "laea"
722+
assert from_template("antarctica", preserve="shape").attrs["crs"] == 3031
723+
724+
685725
@pytest.mark.parametrize(
686726
"name,crs,wkt_marker",
687727
[("web_mercator", 3857, "Pseudo-Mercator"),

0 commit comments

Comments
 (0)