darts_acquisition.arcticdem
¶
Downloading and loading related functions for the Zarr-Datacube approach.
_validate_and_get_accessor
¶
_validate_and_get_accessor(
data_dir: pathlib.Path | str,
resolution: darts_acquisition.arcticdem.RESOLUTIONS,
) -> (
smart_geocubes.ArcticDEM2m
| smart_geocubes.ArcticDEM10m
| smart_geocubes.ArcticDEM32m
)
Source code in darts-acquisition/src/darts_acquisition/arcticdem.py
download_arcticdem
¶
download_arcticdem(
aoi: geopandas.GeoDataFrame,
data_dir: pathlib.Path | str,
resolution: darts_acquisition.arcticdem.RESOLUTIONS,
) -> None
Download ArcticDEM data for the specified area of interest.
This function downloads ArcticDEM elevation tiles from AWS S3 for the given area of interest and stores them in a local icechunk data store for efficient access.
Parameters:
-
aoi(geopandas.GeoDataFrame) –Area of interest for which to download ArcticDEM data. Can be in any CRS; will be reprojected to EPSG:3413 (ArcticDEM's native CRS).
-
data_dir(pathlib.Path | str) –Path to the icechunk data directory (must have .icechunk suffix). Must contain the resolution in the name (e.g., "arcticdem_2m.icechunk").
-
resolution(typing.Literal[2, 10, 32]) –The resolution of the ArcticDEM data in meters. Must match the resolution indicated in the data_dir name.
Note
This function automatically configures AWS access with unsigned requests to the public ArcticDEM S3 bucket. No AWS credentials are required.
Example
Download ArcticDEM for a study area:
import geopandas as gpd
from shapely.geometry import box
from darts_acquisition import download_arcticdem
# Define area of interest
aoi = gpd.GeoDataFrame(
geometry=[box(-50, 70, -49, 71)],
crs="EPSG:4326"
)
# Download 2m resolution ArcticDEM
download_arcticdem(
aoi=aoi,
data_dir="/data/arcticdem_2m.icechunk",
resolution=2
)
Source code in darts-acquisition/src/darts_acquisition/arcticdem.py
load_arcticdem
¶
load_arcticdem(
geobox: odc.geo.geobox.GeoBox,
data_dir: pathlib.Path | str,
resolution: darts_acquisition.arcticdem.RESOLUTIONS,
buffer: int = 0,
offline: bool = False,
) -> xarray.Dataset
Load the ArcticDEM for the given geobox, fetch new data from the STAC server if necessary.
This function loads ArcticDEM elevation data from a local icechunk store. If offline=False,
missing data will be automatically downloaded from the AWS-hosted STAC server and stored
locally for future use. The loaded data is returned in the ArcticDEM's native CRS (EPSG:3413).
Parameters:
-
geobox(odc.geo.geobox.GeoBox) –The geobox for which the tile should be loaded. Must be in a meter-based CRS.
-
data_dir(pathlib.Path | str) –Path to the icechunk data directory (must have .icechunk suffix). This directory stores downloaded ArcticDEM data for faster consecutive access.
-
resolution(typing.Literal[2, 10, 32]) –The resolution of the ArcticDEM data in meters. Must match the resolution indicated in the data_dir name (e.g., "arcticdem_2m.icechunk").
-
buffer(int, default:0) –Buffer around the geobox in pixels. The buffer is applied in the ArcticDEM's native CRS (EPSG:3413) after reprojecting the input geobox. Useful for edge effect removal in terrain analysis. Defaults to 0.
-
offline(bool, default:False) –If True, only loads data already present in the local store without attempting any downloads. If False, missing data is downloaded from AWS. Defaults to False.
Returns:
-
xarray.Dataset–xr.Dataset: The ArcticDEM dataset with the following data variables: - dem (float32): Elevation values in meters, clipped to [-100, 3000] range - arcticdem_data_mask (uint8): Data validity mask (1=valid, 0=invalid)
The dataset is in the ArcticDEM's native CRS (EPSG:3413) with the buffer applied. It is NOT automatically reprojected to match the input geobox's CRS and resolution.
Note
The offline parameter controls data fetching behavior:
- When
offline=False: Usessmart_geocubesaccessor'sload()method which automatically downloads missing tiles from AWS and persists them to the icechunk store. - When
offline=True: Uses the accessor'sopen_xarray()method to open the existing store and crops it to the requested region. Raises an error if data is missing.
Warning
- The input geobox must be in a meter-based CRS.
- The data_dir must have an
.icechunksuffix and contain the resolution in the name. - The returned dataset is in EPSG:3413, not the input geobox's CRS.
Example
Load ArcticDEM with a buffer for terrain analysis:
from math import ceil, sqrt
from darts_acquisition import load_arcticdem
# Assume "optical" is a loaded Sentinel-2 dataset
arcticdem = load_arcticdem(
geobox=optical.odc.geobox,
data_dir="/data/arcticdem_2m.icechunk",
resolution=2,
buffer=ceil(128 / 2 * sqrt(2)), # Buffer for TPI with 128m radius
offline=False
)
# Reproject to match optical data's CRS and resolution
arcticdem = arcticdem.odc.reproject(optical.odc.geobox, resampling="cubic")
Source code in darts-acquisition/src/darts_acquisition/arcticdem.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |