Skip to main content

xcorduroy

Dask aware lightweight DEM utilities for Xarray

Documentation · Usage · Design · API

xcorduroy is a small Xarray accessor for computing hillshade, slope and aspect from DEMs, with dask, numpy, xarray and xproj as its only dependencies. Gradients use the Horn (1981) 3x3 kernel; aspect and hillshade follow the ESRI/GDAL conventions (not numerically cross-checked against gdaldem). Chunked arrays are handled with a dask halo, so lazy and in-memory results are identical.

Warning: experimental. APIs may change without notice.

Installation

uv add xcorduroy
# or
pip install xcorduroy

Example

import xarray as xr
import xproj    # registers the .proj accessor
import xcorduroy  # registers the .dem accessor

ds = xr.open_dataset("DEM.zarr", engine="zarr", chunks="auto")
ds = ds.proj.assign_crs(spatial_ref="EPSG:4326")

slope = ds["dem"].dem.slope()          # degrees, 0-90
aspect = ds["dem"].dem.aspect()        # degrees clockwise from north; flat cells NaN
hillshade = ds["dem"].dem.hillshade()  # 0-1, light from azimuth 315 / altitude 45

A plotted, runnable version is in notebooks/DEM_example.ipynb. See Usage for resolution=, z_factor=, dimension naming and chunking, and Design for the conventions and the degree-to-metre approximation.

Scope

The methods are inspired by xdem and xarray-spatial. If you need well-validated functions for scientific analysis, use one of those. This is a limited-scope, lightweight take on a few of the methods, not a replacement.

Development

uv sync --all-groups
uv run pytest tests -n auto     # tests
uv run ty check src/            # type check
uv run prek run --all-files     # lint and format
uv run mkdocs serve             # docs preview

See Contributing.

What's in the name

Corduroy is the textured snow surface left by groomers, regular peaks and valleys.

Metadata

Release files for xcorduroy 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xcorduroy 0.0.3
File Size Uploaded
xcorduroy-0.0.3.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xcorduroy 0.0.3
File Interpreter ABI Platform
xcorduroy-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.8 kB

Release files / xcorduroy-0.0.3.tar.gz

Download URL xcorduroy-0.0.3.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3a87673c2b8a58f1292b66e36170d532944183ae22515d42f3c5382ec826c4bf
BLAKE2b-256 checksum
How to use checksums
e819cdc713586b6a564f9db85cc4172f70dd1b3bc716c51c4cfd323da9e3ff36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}

Release files / xcorduroy-0.0.3-py3-none-any.whl

Download URL xcorduroy-0.0.3-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e70a4a7bd33eff6ee98f3ac286f350198f2f0d496fa35cc3c3b4bfc88289d0ed
BLAKE2b-256 checksum
How to use checksums
433d30fb975953b37366b6b96c77c022c15baddf99314a3e932c1cbbc77a6ac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page