Dask aware lightweight DEM utilities for Xarray
Project description
xCorduroy - Dask aware lightweight DEM utilities for Xarray
xcorduroy is a lightweight (dask, numpy, xarray and xproj) Xarray accessor for library for calculating hillshade, slope angle and aspects from DEMs.
Warning: experimental
Usage
Installation
uv add xcorduroy
# or
pip install xcorduroy
Notebooks
An example notebook can be found in notebooks/DEM_example.ipynb
Example
import xarray as xr
import xcorduroy # This is needed for the .dem accessor
import xproj # This is needed for the .proj accessor
# Load a 2D Raster DEM
ds = xr.open_dataset("DEM.zarr", engine="zarr", chunks="auto")
# Make sure you have a crs registered
ds = ds.proj.assign_crs("EPSG:4326")
# Calculate hillshade. Note you can use the `dem` accessor.
hillshade = ds['dem'].dem.hillshade()
slope = ds['dem'].dem.slope()
aspect = ds['dem'].dem.aspect()
# Plotting
fig, axes = plt.subplots(2, 2, figsize=(12, 10), sharex=True, sharey=True)
ds['dem'].plot(ax=axes[0, 0], cmap='terrain', add_colorbar=True)
axes[0, 0].set_title("Input DEM")
slope.plot(ax=axes[0, 1], cmap='magma')
axes[0, 1].set_title("Slope")
aspect.plot(ax=axes[1, 0], cmap='twilight')
axes[1, 0].set_title("Aspect")
hillshade.plot(ax=axes[1, 1], cmap='gray')
axes[1, 1].set_title("Hillshade")
plt.tight_layout()
Methods
The three current methods implemented are .hillshade(), .slope() and .aspect(). The hillshade method is based off of the Horn, 1981 method. Details can be found in src/xcorduroy/DEM.py. They are inspired by similar methods in xdem and xarray-spatial. If you are looking for well-validated functions for scientific analysis, check out either of them. This library is a limited scope lightweight take on some of the methods, not a replacement.
Development
This project uses uv for dependency management, pytest and hypothesis for testing, ty for type-checking and ruff for linting.
Sync development environment
uv sync --all-extras
Run type checking
uv run ty check
Run linter
uv run pre-commit run all-files
Run tests
uv run pytest tests/
What's in the name
Corduroy is a textured snow surface left by groomers that forms regular peaks and valleys.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xcorduroy-0.0.2.tar.gz.
File metadata
- Download URL: xcorduroy-0.0.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8f822d658c96ac2a9f7f0f435c9a9979cc460750a616ffa39c868de16597845
|
|
| MD5 |
5e2c88d2f0212c59f2389ac3c3d34bf1
|
|
| BLAKE2b-256 |
1ae769a9bd2b744a8d7b4d6b4ceffef787a32900bb9e987d02e1d35ae3ef86f9
|
File details
Details for the file xcorduroy-0.0.2-py3-none-any.whl.
File metadata
- Download URL: xcorduroy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d941ff8cb7a8636caaf3749dd8c83589f3b9d491780d793116a9b6de99fc3bb
|
|
| MD5 |
64c9ad78793e93a19cc2c3cea25a3e6c
|
|
| BLAKE2b-256 |
58ad7d6654b83cc77f93806ea88cab31edd4456c5d09248f1a1add04652e7b5e
|