Skip to content

Commit e6e05d6

Browse files
authored
Add from_template(): empty study-area DataArrays for common regions (#3484) (#3487)
* Add from_template() study-area grid factory (#3484) New xrspatial.templates module with from_template(name), exported at the top level. Resolves curated region names (conus -> Albers EPSG:5070, nyc, europe, world, ...) and ISO-3166 / GADM alpha-3 country codes (EPSG:4326) to an empty NaN-filled DataArray that obeys the array contract. Supports numpy, dask+numpy, cupy, and dask+cupy backends. Country bounding boxes derived from Natural Earth 50m admin_0 (public domain). * Add templates reference docs and README feature row (#3484) * Add Templates user guide notebook (#3484) * Address review: explicit dask+cupy meta, doc _MAX_CELLS, quiet slope test (#3484) * Add preserve= to from_template: EPSG-coded projection by property (#3484) preserve='area' returns an equal-area EPSG (curated national code, e.g. 5070/3035, or EPSG:8857 Equal Earth fallback); preserve='shape' returns a conformal EPSG (the centroid's UTM/UPS zone, with curated overrides for europe/world). attrs['crs'] stays an int EPSG. Reuses _edge_samples/ _transform_boundary to project the lon/lat bbox and query_utm_crs_info for the zone; requires pyproj. distance/direction are not offered (no EPSG-coded equidistant/azimuthal projections exist). * Document preserve= in README and user guide notebook (#3484) * Clamp world preserve-path latitude to +/-85 so shape (Mercator) doesn't diverge (#3484)
1 parent 52105da commit e6e05d6

9 files changed

Lines changed: 1964 additions & 1 deletion

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Each cell shows the **feature tier** for that function on that backend (see [iss
150150

151151
✅ stable · 🔼 advanced · 🧪 experimental · 🔧 internal · 🚫 unsupported
152152

153-
[GeoTIFF / COG I/O](#geotiff--cog-io) · [Classification](#classification) · [Diffusion](#diffusion) · [Focal](#focal) · [Morphological](#morphological) · [Fire](#fire) · [Multispectral](#multispectral) · [Multivariate](#multivariate) · [MCDA](#multi-criteria-decision-analysis-mcda) · [Pathfinding](#pathfinding) · [Proximity](#proximity) · [Reproject / Merge](#reproject--merge) · [Raster / Vector Conversion](#raster--vector-conversion) · [Surface](#surface) · [Hydrology](#hydrology) · [Flood](#flood) · [Interpolation](#interpolation) · [Dasymetric](#dasymetric) · [Zonal](#zonal) · [Utilities](#utilities)
153+
[GeoTIFF / COG I/O](#geotiff--cog-io) · [Classification](#classification) · [Diffusion](#diffusion) · [Focal](#focal) · [Morphological](#morphological) · [Fire](#fire) · [Multispectral](#multispectral) · [Multivariate](#multivariate) · [MCDA](#multi-criteria-decision-analysis-mcda) · [Pathfinding](#pathfinding) · [Proximity](#proximity) · [Reproject / Merge](#reproject--merge) · [Raster / Vector Conversion](#raster--vector-conversion) · [Surface](#surface) · [Hydrology](#hydrology) · [Flood](#flood) · [Interpolation](#interpolation) · [Dasymetric](#dasymetric) · [Zonal](#zonal) · [Templates](#templates) · [Utilities](#utilities)
154154

155155
-------
156156
### **GeoTIFF / COG I/O**
@@ -270,6 +270,14 @@ Built-in Numba JIT and CUDA projection kernels bypass pyproj for per-pixel coord
270270

271271
-----------
272272

273+
### **Templates**
274+
275+
| Name | Description | Source | NumPy xr.DataArray | Dask xr.DataArray | CuPy GPU xr.DataArray | Dask GPU xr.DataArray |
276+
|:----------:|:------------|:------:|:----------------------:|:--------------------:|:-------------------:|:------:|
277+
| [from_template](xrspatial/templates.py) | Empty study-area grid for a named region (CONUS, NYC, ...) or country code; `preserve='area'/'shape'` picks an EPSG projection by property | Custom || 🔼 | 🔼 | 🔼 |
278+
279+
-----------
280+
273281
### **Surface**
274282

275283
| Name | Description | Source | NumPy xr.DataArray | Dask xr.DataArray | CuPy GPU xr.DataArray | Dask GPU xr.DataArray |

docs/source/reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Reference
2929
reproject
3030
resample
3131
surface
32+
templates
3233
terrain_metrics
3334
utilities
3435
zonal
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.. _reference.templates:
2+
3+
*********
4+
Templates
5+
*********
6+
7+
Empty study-area grids you can start an analysis from. ``from_template`` turns
8+
a region name or country code into a NaN-filled :class:`xarray.DataArray` that
9+
follows the xarray-spatial array contract, so it feeds straight into the rest
10+
of the library.
11+
12+
From Template
13+
=============
14+
.. autosummary::
15+
:toctree: _autosummary
16+
17+
xrspatial.templates.from_template

0 commit comments

Comments
 (0)