arcticdem
darts_acquisition.arcticdem
¶
Downloading and loading related functions for the Zarr-Datacube approach.
load_arcticdem
¶
load_arcticdem(
geobox: odc.geo.geobox.GeoBox,
data_dir: pathlib.Path | str,
resolution: darts_acquisition.arcticdem.RESOLUTIONS,
buffer: int = 0,
persist: bool = True,
) -> xarray.Dataset
Load the ArcticDEM for the given geobox, fetch new data from the STAC server if necessary.
Parameters:
-
geobox
(odc.geo.geobox.GeoBox
) –The geobox for which the tile should be loaded.
-
data_dir
(pathlib.Path | str
) –The directory where the ArcticDEM data is stored.
-
resolution
(typing.Literal[2, 10, 32]
) –The resolution of the ArcticDEM data in m.
-
buffer
(int
, default:0
) –The buffer around the projected (epsg:3413) geobox in pixels. Defaults to 0.
-
persist
(bool
, default:True
) –If the data should be persisted in memory. If not, this will return a Dask backed Dataset. Defaults to True.
Returns:
-
xarray.Dataset
–xr.Dataset: The ArcticDEM tile, with a buffer applied. Note: The buffer is applied in the arcticdem dataset's CRS, hence the orientation might be different. Final dataset is NOT matched to the reference CRS and resolution.
Warning
Geobox must be in a meter based CRS.
Usage
Since the API of the load_arcticdem
is based on GeoBox, one can load a specific ROI based on an existing Xarray DataArray:
import xarray as xr
import odc.geo.xr
from darts_aquisition import load_arcticdem
# Assume "optical" is an already loaded s2 based dataarray
arcticdem = load_arcticdem(
optical.odc.geobox,
"/path/to/arcticdem-parent-directory",
resolution=2,
buffer=ceil(self.tpi_outer_radius / 2 * sqrt(2))
)
# Now we can for example match the resolution and extent of the optical data:
arcticdem = arcticdem.odc.reproject(optical.odc.geobox, resampling="cubic")
The buffer
parameter is used to extend the region of interest by a certain amount of pixels.
This comes handy when calculating e.g. the Topographic Position Index (TPI), which requires a buffer around the region of interest to remove edge effects.
Raises:
-
ValueError
–If the resolution is not supported.