rio-stac
raw JSON → 0.12.0 verified Fri May 01 auth: no python
Create SpatioTemporal Asset Catalog (STAC) Items from raster datasets using Rasterio. Version 0.12.0 dropped Python 3.9 support. Release cadence is irregular, with several minor releases per year.
pip install rio-stac Common errors
error AttributeError: module 'rio_stac' has no attribute 'stac' ↓
cause Incorrect import pattern: `from rio_stac import stac` or `rio_stac.stac(...)`
fix
Use
rio_stac.create_stac_item() directly. error TypeError: create_stac_item() missing 1 required positional argument: 'input_datetime' ↓
cause Missing the required `input_datetime` parameter.
fix
Pass an ISO datetime string or set to None (but prefer explicit datetime).
error rio_stac.errors.DateParsingError: Could not parse datetime from raster metadata ↓
cause The TIFF tags do not contain a valid datetime or the format is unsupported.
fix
Always provide an explicit
input_datetime parameter. Warnings
breaking Dropped Python 3.9 support in version 0.12.0. Python 3.10+ required. ↓
fix Upgrade Python to 3.10 or higher, or pin rio-stac to <0.12.0.
gotcha The `input_datetime` parameter is required for `create_stac_item()`. If the raster's TIFF tags contain a datetime, it can be parsed automatically (use `input_datetime=None`), but this may fail silently. ↓
fix Always supply `input_datetime` explicitly, or ensure the raster has valid TIFF DateTime tags.
deprecated The `geom` parameter in `create_stac_item` was deprecated in 0.10.0 in favor of `geometry`. ↓
fix Use `geometry` instead of `geom`.
gotcha When using `assets` parameter, the 'href' inside each asset must be an absolute URL or local path; relative paths may cause unexpected errors. ↓
fix Use absolute URIs for asset hrefs.
Imports
- rio_stac wrong
from rio_stac import staccorrectimport rio_stac - stac wrong
from rio_stac import staccorrectimport rio_stac
Quickstart
import rio_stac
from pystac import Item
# Create a STAC item from a raster file
item = rio_stac.create_stac_item(
"https://example.com/sample.tif",
input_datetime="2023-01-01T00:00:00Z",
assets={"image": {"href": "https://example.com/sample.tif"}},
)
print(item.to_dict())