pystac.serialization#

class pystac.serialization.STACVersionRange(min_version: str | STACVersionID = '0.8.0', max_version: str | STACVersionID | None = None)[source]#

Defines a range of STAC versions.

pystac.serialization.identify_stac_object(json_dict: dict[str, Any]) STACJSONDescription[source]#

Determines the STACJSONDescription of the provided JSON dict.

Parameters:

json_dict – The dict of STAC JSON to identify.

Returns:

The description of the STAC object serialized in the given dict.

Return type:

STACJSONDescription

pystac.serialization.identify_stac_object_type(json_dict: dict[str, Any]) STACObjectType | None[source]#

Determines the STACObjectType of the provided JSON dict. If the JSON dict does not represent a STAC object, returns None.

Will first try to identify the object using "type" field as described in the guidelines in How to Differentiate STAC Files. If this fails, will fall back to using the pre-1.0 heuristic described in this issue

Parameters:

json_dict – The dict of JSON to identify.

pystac.serialization.merge_common_properties(item_dict: dict[str, Any], collection_cache: CollectionCache | None = None, json_href: str | None = None) bool[source]#

Merges Collection properties into an Item.

Note: This is only applicable to reading old STAC versions (pre 1.0.0-beta.1).

Parameters:
  • item_dict – JSON dict of the Item which properties should be merged into.

  • collection_cache – Optional CollectionCache that will be used to read and write cached collections.

  • json_href – The HREF of the file that this JSON comes from. Used to resolve relative paths.

Returns:

True if Collection properties have been merged, otherwise False.

Return type:

bool

pystac.serialization.migrate_to_latest(json_dict: dict[str, Any], info: STACJSONDescription) dict[str, Any][source]#

Migrates the STAC JSON to the latest version

Parameters:
  • json_dict – The dict of STAC JSON to identify.

  • info – The info from identify_stac_object() that describes the STAC object contained in the JSON dict.

Returns:

A copy of the dict that is migrated to the latest version (the version that is pystac.version.STACVersion.DEFAULT_STAC_VERSION)

Return type:

dict