pytac.extensions.classification#

Implements the Classification.

class pystac.extensions.classification.AssetClassificationExtension(asset: Asset)[source]#
asset: pystac.Asset#
asset_href: str#
properties: dict[str, Any]#

The Asset fields, including extension properties.

class pystac.extensions.classification.Bitfield(properties: dict[str, Any])[source]#

Encodes the representation of values as bits in an integer.

Use Bitfield.create to create a new Bitfield.

apply(offset: int, length: int, classes: list[Classification], roles: list[str] | None = None, description: str | None = None, name: str | None = None) None[source]#

Sets the properties for this Bitfield.

Parameters:
  • offset – describes the position of the least significant bit captured by this bitfield, with zero indicating the least significant binary digit

  • length – the number of bits described by this bitfield

  • classes – a list of Classification objects describing the various levels captured by this bitfield

  • roles – the optional role of this bitfield (see Asset Roles <https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#asset-roles>)

  • description – an optional short description of the classification

  • name – the optional name of the class for machine readability

property classes: list[Classification]#

Get or set the class definitions for the bitfield

Returns:

List[Classification]

classmethod create(offset: int, length: int, classes: list[Classification], roles: list[str] | None = None, description: str | None = None, name: str | None = None) Bitfield[source]#

Sets the properties for this Bitfield.

Parameters:
  • offset – describes the position of the least significant bit captured by this bitfield, with zero indicating the least significant binary digit

  • length – the number of bits described by this bitfield

  • classes – a list of Classification objects describing the various levels captured by this bitfield

  • roles – the optional role of this bitfield (see Asset Roles <https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#asset-roles>)

  • description – an optional short description of the classification

  • name – the optional name of the class for machine readability

property description: str | None#

Get or set the optional description of a bitfield.

Returns:

Optional[str]

property length: int#

Get or set the length (number of bits) of the bitfield

Returns:

int

property name: str | None#

Get or set the optional name of the bitfield.

Returns:

Optional[str]

property offset: int#

Get or set the offset of the bitfield.

Describes the position of the least significant bit captured by this bitfield, with zero indicating the least significant binary digit

Returns:

int

properties: dict[str, Any]#
property roles: list[str] | None#

Get or set the role of the bitfield.

See Asset Roles <https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#asset-roles>

Returns:

Optional[List[str]]

to_dict() dict[str, Any][source]#

Returns the dictionary encoding of this bitfield

Returns:

The serialization of the Bitfield

Return type:

dict

class pystac.extensions.classification.Classification(properties: dict[str, Any])[source]#

Represents a single category of a classification.

Use Classification.create to create a new Classification.

apply(value: int, description: str, name: str | None = None, color_hint: str | None = None) None[source]#

Set the properties for a new Classification.

Parameters:
  • value – The integer value corresponding to this class

  • description – The description of this class

  • name – The optional human-readable short name for this class

  • color_hint – An optional hexadecimal string-encoded representation of the RGB color that is suggested to represent this class (six hexadecimal characters, all capitalized)

property color_hint: str | None#

Get or set the optional color hint for this class.

The color hint must be a six-character string of capitalized hexadecimal characters ([0-9A-F]).

Returns:

Optional[str]

classmethod create(value: int, description: str, name: str | None = None, color_hint: str | None = None) Classification[source]#

Create a new Classification.

Parameters:
  • value – The integer value corresponding to this class

  • name – The human-readable short name for this class

  • description – The optional long-form description of this class

  • color_hint – An optional hexadecimal string-encoded representation of the RGB color that is suggested to represent this class (six hexadecimal characters, all capitalized)

property description: str#

Get or set the description of the class

Returns:

str

property name: str | None#

Get or set the name of the class

Returns:

Optional[str]

properties: dict[str, Any]#
to_dict() dict[str, Any][source]#

Returns the dictionary encoding of this class

Returns:

The serialization of the Classification

Return type:

dict

property value: int#

Get or set the class value

Returns:

int

class pystac.extensions.classification.ClassificationExtension[source]#

An abstract class that can be used to extend the properties of Item, Asset, RasterBand, or AssetDefinition with properties from the Classification Extension. This class is generic over the type of STAC object being extended.

This class is not to be instantiated directly. One can either directly use the subclass corresponding to the object you are extending, or the ext class method can be used to construct the proper class for you.

apply(classes: list[Classification] | None = None, bitfields: list[Bitfield] | None = None) None[source]#

Applies the classifiation extension fields to the extended object.

Note: one may set either the classes or bitfields objects, but not both.

Parameters:

classes – a list of Classification objects describing the various classes in the classification

property bitfields: list[Bitfield] | None#

Get or set the bitfields for the base object

Note: Setting the bitfields will clear the object’s classes if they are not None

Returns:

Optional[List[Bitfield]]

property classes: list[Classification] | None#

Get or set the classes for the base object

Note: Setting the classes will clear the object’s bitfields if they are not None

Returns:

Optional[List[Classification]]

classmethod ext(obj: T, add_if_missing: bool = False) ClassificationExtension[T][source]#

Extends the given STAC object with propertied from the Classification Extension

This extension can be applied to instances of Item, Asset, AssetDefinition, or RasterBand.

Raises:

pystac.ExtensionTypeError – If an invalid object type is passed

classmethod get_schema_uri() str[source]#

Gets the schema URI associated with this extension.

classmethod get_schema_uris() list[str][source]#

Gets a list of schema URIs associated with this extension.

name: Literal['classification'] = 'classification'#
properties: dict[str, Any]#

The Asset fields, including extension properties.

classmethod summaries(obj: Collection, add_if_missing: bool = False) SummariesClassificationExtension[source]#
class pystac.extensions.classification.ClassificationExtensionHooks[source]#
migrate(obj: dict[str, Any], version: STACVersionID, info: STACJSONDescription) None[source]#

Migrate a STAC Object in dict format from a previous version. The base implementation will update the stac_extensions to the latest schema ID. This method will only be called for STAC objects that have been identified as a previous version of STAC. Implementations should directly manipulate the obj dict. Remember to call super() in order to change out the old ‘stac_extension’ entry with the latest schema URI.

prev_extension_ids = {'https://stac-extensions.github.io/classification/v1.0.0/schema.json'}#
schema_uri: str = 'https://stac-extensions.github.io/classification/v1.1.0/schema.json'#
stac_object_types = {Feature}#
class pystac.extensions.classification.ItemAssetsClassificationExtension(item_asset: AssetDefinition)[source]#
asset_defn: item_assets.AssetDefinition#
properties: dict[str, Any]#

The Asset fields, including extension properties.

class pystac.extensions.classification.ItemClassificationExtension(item: Item)[source]#
item: pystac.Item#
properties: dict[str, Any]#

The Asset fields, including extension properties.

class pystac.extensions.classification.RasterBandClassificationExtension(raster_band: RasterBand)[source]#
properties: dict[str, Any]#

The Asset fields, including extension properties.

raster_band: RasterBand#
class pystac.extensions.classification.SummariesClassificationExtension(collection: Collection)[source]#
property bitfields: list[Bitfield] | None#
property classes: list[Classification] | None#