linz-stac-utils
linz-stac-utils is a small Python library for querying and loading public LINZ elevation datasets from the nz-elevation STAC catalog hosted in S3.
It exists to make LINZ elevation access simpler in Python scripts and notebooks. Instead of repeatedly wiring together pystac-client, cached catalog requests, and odc.stac loading logic, this package provides a thin reusable wrapper around that workflow.
What It Does
- opens the public LINZ elevation STAC catalog
- fetches collection and item metadata
- loads STAC results into
xarrayobjects withodc.stac - loads a New Zealand elevation surface, preferring the LiDAR 1 m DEM and using the contour-interpolated 8 m DEM to fill LiDAR gaps
- optionally exports the loaded surface as a Cloud Optimized GeoTIFF
Current Scope
- Python API only
- focused on the public
nz-elevationcatalog - aimed at data access, loading, and optional DEM export rather than a general CLI workflow
This is an independent project and is not affiliated with or endorsed by Land Information New Zealand (LINZ).
Installation
Requirements:
- Python 3.11+
Install with uv:
uv add linz-stac-utils
Or install with pip:
python -m pip install linz-stac-utils
Usage
Load an elevation surface for a bounding box at a chosen output resolution. Valid LiDAR pixels take precedence; the contour-interpolated 8 m DEM fills locations without LiDAR coverage:
from linz_stac_utils import load_elevation
elevation = load_elevation(
bbox=(172.6300, -43.5350, 172.6400, -43.5250),
resolution=10,
output_path="christchurch-dem.tif",
)
load_elevation() follows the spatial portion of odc.stac.load:
- Provide exactly one of
bboxorintersects; calls with neither or both are rejected. bboxis(min_longitude, min_latitude, max_longitude, max_latitude)inEPSG:4326.intersectsaccepts an ODC geometry, Shapely geometry, GeoJSON mapping, or an object with__geo_interface__; Shapely and GeoJSON inputs are interpreted asEPSG:4326.crsdefaults toEPSG:2193;resolutionis required and is in the output CRS units.intersectscrops and masks the output polygon with all touched pixels retained.- The latest valid LiDAR value takes precedence for each pixel. The contour surface fills only pixels with no valid LiDAR value.
- Supplying
chunksreturns a Dask-backed surface and preserves spatial chunk boundaries. - Set
overwrite=Trueto replace an existing output file.
Use a polygon when the rectangular bbox is not precise enough:
from shapely.geometry import Polygon
elevation = load_elevation(
intersects=Polygon(
[
(172.6300, -43.5350),
(172.6400, -43.5350),
(172.6350, -43.5250),
]
),
resolution=10,
)
For lower-level catalog access, use StacCatalogClient directly:
from linz_stac_utils import StacCatalogClient
client = StacCatalogClient()
dataset = client.load(
collections=["01JE4ZZWAG19KPKRHYJJP02HC9"],
bbox=(172.6300, -43.5350, 172.6400, -43.5250),
resolution=1000,
)
load() filters static-catalog items locally before loading them. It supports
bbox, intersects, item IDs, and a positive result limit. It defaults to
EPSG:2193, and resolutions are specified in the output CRS units.
See the regional elevation example for an interactive workflow.
Notes
- network access is required to read remote catalog and raster data
- STAC API responses are cached locally with
requests-cachefor one day by default. The cache is created when a client is initialized in your platform's user cache directory, rather than in the installed package directory. - LINZ describes the contour-interpolated 8 m DEM as suitable for cartographic visualization and not suitable for terrain analysis. Its use as a fallback does not make the output a LiDAR-quality terrain model.
Configure caching by creating and injecting a STAC IO instance:
from pathlib import Path
from linz_stac_utils import StacCatalogClient, build_stac_io
client = StacCatalogClient(
stac_io=build_stac_io(
cache_path=Path("data/stac.sqlite"),
expire_after=3600,
)
)
Pass cache=False to build_stac_io() to use an uncached STAC session.
Development
Install the project and development dependencies:
uv sync
Run tests:
uv run pytest
Run linting:
uv run ruff check .
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 linz_stac_utils-0.1.0.tar.gz.
File metadata
- Download URL: linz_stac_utils-0.1.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29212974edc2267cda73412ce5e64e7d39d512c508fae079749da54edb1c3d61
|
|
| MD5 |
6439370af3717d66ec014dffd9f2c0f1
|
|
| BLAKE2b-256 |
5be93ec8242aab3bcc620bf250515b89cf3b32c1071c9781ec01ae1ecc86d33f
|
Provenance
The following attestation bundles were made for linz_stac_utils-0.1.0.tar.gz:
Publisher:
publish.yml on quinnhornblow/linz-stac-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linz_stac_utils-0.1.0.tar.gz -
Subject digest:
29212974edc2267cda73412ce5e64e7d39d512c508fae079749da54edb1c3d61 - Sigstore transparency entry: 2264146800
- Sigstore integration time:
-
Permalink:
quinnhornblow/linz-stac-utils@73f4f21e857132de3dd623d0fae281a3239ac251 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/quinnhornblow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73f4f21e857132de3dd623d0fae281a3239ac251 -
Trigger Event:
push
-
Statement type:
File details
Details for the file linz_stac_utils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: linz_stac_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b34fd8002c3bbeb7bc68e12b245da00436034141dcbd4a66bbbbbb355ddcb6
|
|
| MD5 |
b3c36ab750046e4f279026d062a663a0
|
|
| BLAKE2b-256 |
1770049fbe4ecddf4ed97c63a45dd2c4fdc6f0f664c5163a018a14e264fcd44f
|
Provenance
The following attestation bundles were made for linz_stac_utils-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on quinnhornblow/linz-stac-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
linz_stac_utils-0.1.0-py3-none-any.whl -
Subject digest:
a4b34fd8002c3bbeb7bc68e12b245da00436034141dcbd4a66bbbbbb355ddcb6 - Sigstore transparency entry: 2264147074
- Sigstore integration time:
-
Permalink:
quinnhornblow/linz-stac-utils@73f4f21e857132de3dd623d0fae281a3239ac251 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/quinnhornblow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73f4f21e857132de3dd623d0fae281a3239ac251 -
Trigger Event:
push
-
Statement type: