Skip to content

Migration

stacrs.migrate

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:

  • value (dict[str, Any]) –

    The STAC value to migrate

  • version (str | None, default: None ) –

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

Returns:

  • 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

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:

  • href (str) –

    The href to read the STAC object from

  • version (str | None, default: None ) –

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

Examples:

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