pytac.extensions.classification#
Implements the Classification.
- 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 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
- 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 | None = None, name: str | None = None, color_hint: str | None = None, nodata: bool | None = None, percentage: float | None = None, count: int | 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 – Short name of the class for machine readability. Must consist only of letters, numbers, -, and _ characters. Required as of v2.0 of this extension.
color_hint – An optional hexadecimal string-encoded representation of the RGB color that is suggested to represent this class (six hexadecimal characters, all capitalized)
nodata – If set to true classifies a value as a no-data value.
percentage – The percentage of data values that belong to this class in comparison to all data values, in percent (0-100).
count – The number of data values that belong to this class.
- 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 | None = None, name: str | None = None, color_hint: str | None = None, nodata: bool | None = None, percentage: float | None = None, count: int | None = None) Classification [source]#
Create a new Classification.
- Parameters:
value – The integer value corresponding to this class
description – The optional long-form description of this class
name – Short name of the class for machine readability. Must consist only of letters, numbers, -, and _ characters. Required as of v2.0 of this extension.
color_hint – An optional hexadecimal string-encoded representation of the RGB color that is suggested to represent this class (six hexadecimal characters, all capitalized)
nodata – If set to true classifies a value as a no-data value.
percentage – The percentage of data values that belong to this class in comparison to all data values, in percent (0-100).
count – The number of data values that belong to this class.
- property percentage: float | None#
Get or set the percentage value for this class.
- Returns:
Optional[float]
- class pystac.extensions.classification.ClassificationExtension[source]#
An abstract class that can be used to extend the properties of
Item
,Asset
,RasterBand
, orAssetDefinition
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
, orRasterBand
.- Raises:
pystac.ExtensionTypeError – If an invalid object type is passed
- classmethod get_schema_uris() list[str] [source]#
Gets a list of schema URIs associated with this extension.
- 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', '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: AssetDefinition#
- class pystac.extensions.classification.RasterBandClassificationExtension(raster_band: RasterBand)[source]#
-
- raster_band: RasterBand#