You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#134: add xr.Dataset as input type for appropriate modules (#854)
* Fixes#134: add xr.Dataset as input type for appropriate modules
Add transparent Dataset support via two decorators in a new
dataset_support module. Single-input functions (slope, aspect,
curvature, hillshade, focal.mean, 10 classify functions, 3 proximity
functions) iterate over data_vars and return a Dataset. Multi-input
functions (10 multispectral indices) accept a Dataset with band-name
kwargs. zonal.stats merges per-variable DataFrames with prefixed
columns. Includes 18 new tests.
* Update documentation for xr.Dataset support
Update docstrings, prose docs, notebooks, README, and changelog to
reflect that most public functions now accept xr.Dataset in addition
to xr.DataArray.
Most functions also accept an `xr.Dataset`. Single-input functions (surface, classification, focal, proximity) apply the operation to each data variable and return a Dataset. Multi-input functions (multispectral indices) accept a Dataset with band-name keyword arguments.
264
+
265
+
```python
266
+
# Single-input: returns a Dataset with slope computed for each variable
267
+
slope_ds = slope(my_dataset)
268
+
269
+
# Multi-input: map Dataset variables to band parameters
Copy file name to clipboardExpand all lines: docs/source/user_guide/multispectral.ipynb
+3-13Lines changed: 3 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,7 @@
10
10
{
11
11
"cell_type": "markdown",
12
12
"metadata": {},
13
-
"source": [
14
-
"Xarray-spatial's Multispectral tools provide a range of functions pertaining to remote sensing data such as satellite imagery. A range of functions are available to calculate various vegetation and environmental parameters from the range of band data available for an area. These functions accept and output data in the form of xarray.DataArray rasters.\n",
"source": "Xarray-spatial's Multispectral tools provide a range of functions pertaining to remote sensing data such as satellite imagery. A range of functions are available to calculate various vegetation and environmental parameters from the range of band data available for an area. These functions accept and output data in the form of xarray.DataArray rasters. They also accept an xr.Dataset as the first argument with band-name keyword arguments to map variables to bands (e.g. `ndvi(ds, nir='B5', red='B4')`).\n\n- [Generate terrain](#Generate-Terrain-Data) \n- [Bump](#Bump) \n- [NDVI](#NDVI) "
20
14
},
21
15
{
22
16
"cell_type": "markdown",
@@ -64,11 +58,7 @@
64
58
{
65
59
"cell_type": "markdown",
66
60
"metadata": {},
67
-
"source": [
68
-
"The following functions apply to image data with bands in different parts of the UV/Visible/IR spectrum (multispectral), so we'll bring in some multispectral satellite image data to work with.\n",
69
-
"\n",
70
-
"Below, we loaded all of the images and transformed them into the form of an xarray DataArray to use in the Xarray-spatial functions."
71
-
]
61
+
"source": "The following functions apply to image data with bands in different parts of the UV/Visible/IR spectrum (multispectral), so we'll bring in some multispectral satellite image data to work with.\n\nBelow, we loaded all of the images and transformed them into the form of an xarray DataArray to use in the Xarray-spatial functions. Note: you can also load bands into an `xr.Dataset` and pass it directly to multispectral functions with band-name keyword arguments (e.g. `ndvi(ds, nir='nir', red='red')`)."
Copy file name to clipboardExpand all lines: docs/source/user_guide/surface.ipynb
+2-12Lines changed: 2 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,7 @@
10
10
{
11
11
"cell_type": "markdown",
12
12
"metadata": {},
13
-
"source": [
14
-
"With the Surface tools, you can quantify and visualize a terrain landform represented by a digital elevation model.\n",
15
-
"\n",
16
-
"Starting with a raster elevation surface that represented as an Xarray DataArray, these tools help you in identifying some specific patterns that were not readily apparent in the original surface. Return of each function is also an Xarray DataArray.\n",
17
-
"\n",
18
-
"- [Hillshade](#Hillshade): Creates a shaded relief from a surface raster by considering the illumination source angle and shadows.\n",
19
-
"- [Slope](#Slope): Identifies the slope from each cell of a raster.\n",
20
-
"- [Curvature](#Curvature): Calculates the curvature of a raster surface.\n",
21
-
"- [Aspect](#Aspect): Derives the aspect from each cell of a raster surface.\n",
22
-
"- [Viewshed](#Viewshed): Determines visible locations in the input raster surface from a viewpoint with some optional observer features."
23
-
]
13
+
"source": "With the Surface tools, you can quantify and visualize a terrain landform represented by a digital elevation model.\n\nStarting with a raster elevation surface that represented as an Xarray DataArray (or an Xarray Dataset containing multiple elevation variables), these tools help you in identifying some specific patterns that were not readily apparent in the original surface. When a DataArray is passed, the return is a DataArray. When a Dataset is passed, the function is applied to each variable independently and the return is a Dataset.\n\n- [Hillshade](#Hillshade): Creates a shaded relief from a surface raster by considering the illumination source angle and shadows.\n- [Slope](#Slope): Identifies the slope from each cell of a raster.\n- [Curvature](#Curvature): Calculates the curvature of a raster surface.\n- [Aspect](#Aspect): Derives the aspect from each cell of a raster surface.\n- [Viewshed](#Viewshed): Determines visible locations in the input raster surface from a viewpoint with some optional observer features."
Copy file name to clipboardExpand all lines: examples/user_guide/1_Surface.ipynb
+2-21Lines changed: 2 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,7 @@
3
3
{
4
4
"cell_type": "markdown",
5
5
"metadata": {},
6
-
"source": [
7
-
"# Xarray-spatial\n",
8
-
"### User Guide: Surface tools\n",
9
-
"-----\n",
10
-
"With the Surface tools, you can quantify and visualize a terrain landform represented by a digital elevation model.\n",
11
-
"\n",
12
-
"Starting with a raster elevation surface, represented as an Xarray DataArray, these tools can help you identify some specific patterns that may not be readily apparent in the original surface. The return of each function is also an Xarray DataArray.\n",
13
-
"\n",
14
-
"[Hillshade](#Hillshade): Creates a shaded relief from a surface raster by considering the illumination source angle and shadows.\n",
15
-
"\n",
16
-
"[Slope](#Slope): Identifies the slope for each cell of a raster.\n",
17
-
"\n",
18
-
"[Curvature](#Curvature): Calculates the curvature of a raster surface.\n",
19
-
"\n",
20
-
"[Aspect](#Aspect): Derives the aspect for each cell of a raster surface.\n",
21
-
"\n",
22
-
"[Viewshed](#Viewshed): Determines visible locations in the input raster surface from a viewpoint with an optional observer height.\n",
23
-
"\n",
24
-
"-----------\n"
25
-
]
6
+
"source": "# Xarray-spatial\n### User Guide: Surface tools\n-----\nWith the Surface tools, you can quantify and visualize a terrain landform represented by a digital elevation model.\n\nStarting with a raster elevation surface, represented as an Xarray DataArray (or an Xarray Dataset containing multiple elevation variables), these tools can help you identify some specific patterns that may not be readily apparent in the original surface. When a DataArray is passed, the return is a DataArray. When a Dataset is passed, the function is applied to each variable independently and the return is a Dataset.\n\n[Hillshade](#Hillshade): Creates a shaded relief from a surface raster by considering the illumination source angle and shadows.\n\n[Slope](#Slope): Identifies the slope for each cell of a raster.\n\n[Curvature](#Curvature): Calculates the curvature of a raster surface.\n\n[Aspect](#Aspect): Derives the aspect for each cell of a raster surface.\n\n[Viewshed](#Viewshed): Determines visible locations in the input raster surface from a viewpoint with an optional observer height.\n\n-----------\n"
Copy file name to clipboardExpand all lines: examples/user_guide/6_Remote_Sensing.ipynb
+3-24Lines changed: 3 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -3,24 +3,7 @@
3
3
{
4
4
"cell_type": "markdown",
5
5
"metadata": {},
6
-
"source": [
7
-
"# Xarray-spatial\n",
8
-
"### User Guide: Remote Sensing tools\n",
9
-
"-----\n",
10
-
"\n",
11
-
"Xarray-spatial's Remote Sensing tools provide a range of functions pertaining to remote sensing data such as satellite imagery. A range of functions are available to calculate various vegetation and environmental parameters from the range of band data available for an area. These functions accept and output data in the form of xarray.DataArray rasters.\n",
"[Normalized Difference Moisture Index - NDMI](#Normalized-Difference-Moisture-Index-(NDMI)) \n",
18
-
"[Structure Insensitive Pigment Index - SIPI](#Structure-Insensitive-Pigment-Index-(SIPI)) \n",
19
-
"[Enhanced Built-Up and Bareness Index - EBBI](#Enhanced-Built-Up-and-Bareness-Index-(EBBI)) \n",
20
-
"[Bump Mapping](#Bump-Mapping) \n",
21
-
"\n",
22
-
"-----------\n"
23
-
]
6
+
"source": "# Xarray-spatial\n### User Guide: Remote Sensing tools\n-----\n\nXarray-spatial's Remote Sensing tools provide a range of functions pertaining to remote sensing data such as satellite imagery. A range of functions are available to calculate various vegetation and environmental parameters from the range of band data available for an area. These functions accept and output data in the form of xarray.DataArray rasters. They also accept an xr.Dataset as the first argument with band-name keyword arguments to map variables to bands (e.g. `ndvi(ds, nir='B5', red='B4')`).\n\n[True Color](#True-Color) \n[Vegetation Index](#Vegetation-Index): [NDVI](#NDVI), [SAVI](#SAVI), [ARVI](#ARVI), [EVI](#EVI) \n[Green Chlorophyll Index - GCI](#Green-Chlorophyll-Index-(GCI)) \n[Normalized Burn Ratio](#Normalized-Burn-Ratio): [NBR](#NBR), [NBR2](#NBR2) \n[Normalized Difference Moisture Index - NDMI](#Normalized-Difference-Moisture-Index-(NDMI)) \n[Structure Insensitive Pigment Index - SIPI](#Structure-Insensitive-Pigment-Index-(SIPI)) \n[Enhanced Built-Up and Bareness Index - EBBI](#Enhanced-Built-Up-and-Bareness-Index-(EBBI)) \n[Bump Mapping](#Bump-Mapping) \n\n-----------\n"
24
7
},
25
8
{
26
9
"cell_type": "markdown",
@@ -68,11 +51,7 @@
68
51
{
69
52
"cell_type": "markdown",
70
53
"metadata": {},
71
-
"source": [
72
-
"The following functions apply to image data with bands in different parts of the UV/Visible/IR spectrum (multispectral), so we'll bring in some multispectral satellite image data to work with.\n",
73
-
"\n",
74
-
"Below, we loaded all of the images and transformed them into the form of an xarray DataArray to use in the Xarray-spatial functions."
75
-
]
54
+
"source": "The following functions apply to image data with bands in different parts of the UV/Visible/IR spectrum (multispectral), so we'll bring in some multispectral satellite image data to work with.\n\nBelow, we loaded all of the images and transformed them into the form of an xarray DataArray to use in the Xarray-spatial functions. Note: you can also load bands into an `xr.Dataset` and pass it directly to multispectral functions with band-name keyword arguments (e.g. `ndvi(ds, nir='nir', red='red')`)."
0 commit comments