Skip to main content

A rasterio extension to open STAC Items and ItemCollections using native GDAL drivers

Project description

rio-stac-io

From Metadata to Pixels

rio-stac-io is a rasterio extension to open STAC Items, ItemCollections, client search results, and STAC-compliant GeoDataFrame tables (e.g. from STAC GeoParquet) using native GDAL drivers including STACIT, STACTA and GTI. The library is build on top of rasterio and pystac. Full notes and a GeoParquet example are in the documentation.

Documentation

https://planetlabs.github.io/rio-stac-io

Installation

pip install rio-stac-io

When using the GTI driver you will need to install gti extras. Your GDAL binaries need to be compiled with geoparquet support.

pip install rio-stac-io[gti]

Usage

from pystac_client import Client

import rio_stac_io as stacio

client = Client.open(...)
search = client.search(...)

with stacio.open(search, asset_key="data") as src:
    data = src.read()

GeoDataFrame input requires pip install rio-stac-io[gti]; rows must follow a STAC item layout (as in stac-geoparquet). The library tries GTI first, then STACIT if GTI is not usable; the use_gti argument is ignored for this input type. Example: read a GeoParquet file, filter rows, then open the asset key:

import geopandas as gpd
import rio_stac_io as stacio

gdf = gpd.read_parquet("items.parquet")
gdf = gdf[gdf["collection"] == "s2"]

with stacio.open(gdf, asset_key="cog") as src:
    data = src.read()

Development

This repository requires Pixi v0.67.2 or later.

git clone git@github.com:planetlabs/rio-stac-io.git
cd rio-stac-io
pixi shell -e dev

Multiple Pixi environments pin different libgdal versions (e.g. dev, dev-gdal310, dev-gdal312, dev-gdal313, dev-gdal311-noparquet; see pyproject.toml for the full list). Rasterio is installed from source ([tool.pixi.pypi-options] no-binary = ["rasterio"]) so it links against the conda GDAL in that environment.

Troubleshooting: rasterio linked to the wrong GDAL

Switching between any two GDAL environments locally (for example moving between any of the dev-gdal* variants) can leave Pixi's PyPI/build cache holding a rasterio build compiled against a different libgdal. Symptoms include odd GTI or CRS failures, or rasterio.__gdal_version__ not matching gdalinfo --version in the same shell.

Check:

pixi run -e <env> verify-gdal

If that fails, clear the cached build and reinstall the environment (not usually needed on CI—runners are isolated per job):

pixi clean cache --pypi --build -y
rm -rf .pixi/envs/<env>
pixi install -e <env>
pixi run -e <env> verify-gdal

Replace <env> with the environment you use (dev, dev-gdal310, dev-gdal312, dev-gdal313, dev-gdal311-noparquet, …).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rio_stac_io-0.4.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rio_stac_io-0.4.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file rio_stac_io-0.4.0.tar.gz.

File metadata

  • Download URL: rio_stac_io-0.4.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for rio_stac_io-0.4.0.tar.gz
Algorithm Hash digest
SHA256 91a3c737fe527cdc66317ca14087a3ff281cb0c191b1a3c209951d3c50bf9857
MD5 c2bbcec7926977b79162e1f2e476f812
BLAKE2b-256 4b3a4bbdcd92d9c3cc4bb37975ebc96dc23fbe6778c46f4188a5454d13535069

See more details on using hashes here.

File details

Details for the file rio_stac_io-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: rio_stac_io-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for rio_stac_io-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ae7a8a8d670f86bd630a46b10bfa0ce7fa592e7c581696ffe4eb48943b48625
MD5 6c194c3257dfd7324b28d0d32d3a8f88
BLAKE2b-256 d2e252ab32154bfd753a24660e6ca20a73b0c6f8bedaa43c5749fec2ef24bbb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page