Skip to content

Migration

stacrs.migrate builtin

migrate(value: dict[str, Any], version: Optional[str] = None) -> dict[str, Any]

Migrates a STAC dictionary to another version.

Migration can be as simple as updating the stac_version attribute, but sometimes can be more complicated. For example, when migrating to v1.1.0, eo:bands and raster:bands should be consolidated to the new bands structure.

See the stac-rs documentation for supported versions.

Parameters:

Name Type Description Default
value dict[str, Any]

The STAC value to migrate

required
version str | None

The version to migrate to. If not provided, the value will be migrated to the latest stable version.

None

Returns:

Type Description
dict[str, Any]

dict[str, Any]: The migrated dictionary

Examples:

>>> with open("examples/simple-item.json") as f:
>>>     item = json.load(f)
>>> item = stacrs.migrate(item, "1.1.0-beta.1")
>>> assert item["stac_version"] == "1.1.0-beta.1"

stacrs.migrate_href builtin

migrate_href(href: str, version: Optional[str] = None) -> dict[str, Any]

Migrates a STAC dictionary at the given href to another version.

Migration can be as simple as updating the stac_version attribute, but sometimes can be more complicated. For example, when migrating to v1.1.0, eo:bands and raster:bands should be consolidated to the new bands structure.

See the stac-rs documentation for supported versions.

Parameters:

Name Type Description Default
href str

The href to read the STAC object from

required
version str | None

The version to migrate to. If not provided, the value will be migrated to the latest stable version.

None

Examples:

>>> item = stacrs.migrate_href("examples/simple-item.json", "1.1.0-beta.1")
>>> assert item["stac_version"] == "1.1.0-beta.1"