legacy
darts_preprocessing.legacy
¶
PLANET scene based preprocessing.
calculate_ndvi
¶
Calculate NDVI from an xarray Dataset containing spectral bands.
This function will clip the NIR and Red bands to the range [0, 1] before calculating NDVI to avoid potential numerical instabilities from negative reflections.
Parameters:
Returns:
Notes
NDVI (Normalized Difference Vegetation Index) is calculated using the formula: NDVI = (NIR - Red) / (NIR + Red)
Source code in darts-preprocessing/src/darts_preprocessing/engineering/indices.py
calculate_slope
¶
Calculate the slope of the terrain surface from an ArcticDEM Dataset.
Parameters:
Returns:
-
xarray.Dataset
–xr.Dataset: The input Dataset with the calculated slope added as a new variable 'slope'.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/arcticdem.py
calculate_topographic_position_index
¶
calculate_topographic_position_index(
arcticdem_ds: xarray.Dataset,
outer_radius: int,
inner_radius: int,
) -> xarray.Dataset
Calculate the Topographic Position Index (TPI) from an ArcticDEM Dataset.
Parameters:
-
arcticdem_ds
(xarray.Dataset
) –The ArcticDEM Dataset containing the 'dem' variable.
-
outer_radius
(int
) –The outer radius of the annulus kernel in m.
-
inner_radius
(int
) –The inner radius of the annulus kernel in m.
Returns:
-
xarray.Dataset
–xr.Dataset: The input Dataset with the calculated TPI added as a new variable 'tpi'.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/arcticdem.py
preprocess_legacy_arcticdem_fast
¶
preprocess_legacy_arcticdem_fast(
ds_arcticdem: xarray.Dataset,
tpi_outer_radius: int,
tpi_inner_radius: int,
) -> xarray.Dataset
Preprocess the ArcticDEM data with legacy (DARTS v1) preprocessing steps.
Parameters:
-
ds_arcticdem
(xarray.Dataset
) –The ArcticDEM dataset.
-
tpi_outer_radius
(int
) –The outer radius of the annulus kernel for the tpi calculation in number of cells.
-
tpi_inner_radius
(int
) –The inner radius of the annulus kernel for the tpi calculation in number of cells.
Returns:
Source code in darts-preprocessing/src/darts_preprocessing/legacy.py
preprocess_legacy_fast
¶
preprocess_legacy_fast(
ds_optical: xarray.Dataset,
ds_arcticdem: xarray.Dataset,
ds_tcvis: xarray.Dataset,
tpi_outer_radius: int = 100,
tpi_inner_radius: int = 0,
device: typing.Literal["cuda", "cpu"]
| int = darts_utils.cuda.DEFAULT_DEVICE,
) -> xarray.Dataset
Preprocess optical data with legacy (DARTS v1) preprocessing steps, but with new data concepts.
The processing steps are: - Calculate NDVI - Calculate slope and relative elevation from ArcticDEM - Merge everything into a single ds.
The main difference to preprocess_legacy is the new data concept of the arcticdem. Instead of using already preprocessed arcticdem data which are loaded from a VRT, this step expects the raw arcticdem data and calculates slope and relative elevation on the fly.
Parameters:
-
ds_optical
(xarray.Dataset
) –The Planet scene optical data or Sentinel 2 scene optical dataset including data_masks.
-
ds_arcticdem
(xarray.Dataset
) –The ArcticDEM dataset.
-
ds_tcvis
(xarray.Dataset
) –The TCVIS dataset.
-
tpi_outer_radius
(int
, default:100
) –The outer radius of the annulus kernel for the tpi calculation in m. Defaults to 100m.
-
tpi_inner_radius
(int
, default:0
) –The inner radius of the annulus kernel for the tpi calculation in m. Defaults to 0.
-
device
(typing.Literal['cuda', 'cpu'] | int
, default:darts_utils.cuda.DEFAULT_DEVICE
) –The device to run the tpi and slope calculations on. If "cuda" take the first device (0), if int take the specified device. Defaults to "cuda" if cuda is available, else "cpu".
Returns: