pystac.extensions.label#
Implements the Label Extension.
- class pystac.extensions.label.LabelClasses(properties: Dict[str, Any])[source]#
Bases:
objectDefines the list of possible class names (e.g., tree, building, car, hippo).
Use
LabelClasses.create()to create a new instance from property values.- apply(classes: Sequence[Union[str, int, float]], name: Optional[str] = None) None[source]#
Sets the properties for this instance.
- Parameters
classes – The different possible class values.
name – The property key within the asset’s each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise.
- classmethod create(classes: Sequence[Union[str, int, float]], name: Optional[str] = None) pystac.extensions.label.LabelClasses[source]#
Creates a new
LabelClassesinstance.- Parameters
classes – The different possible class values.
name – The property key within the asset’s each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise.
- class pystac.extensions.label.LabelCount(properties: Dict[str, Any])[source]#
Bases:
objectContains counts for categorical data.
Use
LabelCount.create()to create a new instance.- apply(name: str, count: int) None[source]#
Sets the properties for this instance.
- Parameters
name – One of the different possible classes within the property.
count – The number of occurrences of the class.
- classmethod create(name: str, count: int) pystac.extensions.label.LabelCount[source]#
Creates a
LabelCountinstance.- Parameters
name – One of the different possible classes within the property.
count – The number of occurrences of the class.
- class pystac.extensions.label.LabelExtension(item: pystac.item.Item)[source]#
Bases:
pystac.extensions.base.ExtensionManagementMixin[Union[pystac.collection.Collection,pystac.item.Item]]A class that can be used to extend the properties of an
Itemwith properties from the Label Extension.To create an instance of
LabeExtension, use theLabelExtension.ext()method. For example:>>> item: pystac.Item = ... >>> label_ext = LabelExtension.ext(item)
- add_geojson_labels(href: str, title: Optional[str] = None, properties: Optional[Dict[str, Any]] = None) None[source]#
Adds a GeoJSON label asset to this LabelItem.
- Parameters
href – Link to the asset object. Relative and absolute links are both allowed.
title – Optional displayed title for clients and users.
properties – Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON.
- add_labels(href: str, title: Optional[str] = None, media_type: Optional[str] = None, properties: Optional[Dict[str, Any]] = None) None[source]#
Adds a label asset to this LabelItem.
- Parameters
href – Link to the asset object. Relative and absolute links are both allowed.
title – Optional displayed title for clients and users.
media_type – Optional description of the media type. Registered Media Types are preferred. See
MediaTypefor common media types.properties – Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON.
- add_source(source_item: pystac.item.Item, title: Optional[str] = None, assets: Optional[List[str]] = None) None[source]#
Adds a link to a source item.
- Parameters
source_item – Source imagery that the LabelItem applies to.
title – Optional title for the link.
assets – Optional list of assets that determine what assets in the source item this label item data applies to.
- apply(label_description: str, label_type: pystac.extensions.label.LabelType, label_properties: Optional[List[str]] = None, label_classes: Optional[List[pystac.extensions.label.LabelClasses]] = None, label_tasks: Optional[List[Union[pystac.extensions.label.LabelTask, str]]] = None, label_methods: Optional[List[Union[pystac.extensions.label.LabelMethod, str]]] = None, label_overviews: Optional[List[pystac.extensions.label.LabelOverview]] = None) None[source]#
Applies label extension properties to the extended Item.
- Parameters
label_description – A description of the label, how it was created, and what it is recommended for
label_type – An Enum of either vector label type or raster label type. Use one of
LabelType.label_properties – These are the names of the property field(s) in each Feature of the label asset’s FeatureCollection that contains the classes (keywords from label:classes if the property defines classes). If labels are rasters, this should be None.
label_classes – Optional, but required if using categorical data. A list of
LabelClassesinstances defining the list of possible class names for each label:properties. (e.g., tree, building, car, hippo)label_tasks – Recommended to be a subset of ‘regression’, ‘classification’, ‘detection’, or ‘segmentation’, but may be an arbitrary value.
label_methods – Recommended to be a subset of ‘automated’ or ‘manual’, but may be an arbitrary value.
label_overviews – Optional list of
LabelOverviewinstances that store counts (for classification-type data) or summary statistics (for continuous numerical/regression data).
- classmethod ext(obj: pystac.item.Item, add_if_missing: bool = False) pystac.extensions.label.LabelExtension[source]#
Extends the given STAC Object with properties from the Label Extension.
This extension can be applied to instances of
Item.
- get_sources() Iterable[pystac.item.Item][source]#
Gets any source items that describe the source imagery used to generate this LabelItem.
- Returns
A possibly empty list of source imagery items. Determined by links of this LabelItem that have
rel=='source'.
- property label_classes: Optional[List[pystac.extensions.label.LabelClasses]]#
Gets or set a list of
LabelClassesdefining the list of possible class names for each label:properties. (e.g., tree, building, car, hippo).Optional, but required if using categorical data.
- property label_description: str#
Gets or sets a description of the label, how it was created, and what it is recommended for.
- property label_methods: Optional[List[Union[pystac.extensions.label.LabelMethod, str]]]#
Gets or set a list of methods used for labeling.
Usually a subset of ‘automated’ or ‘manual’, but may be arbitrary values.
- property label_overviews: Optional[List[pystac.extensions.label.LabelOverview]]#
Gets or set a list of
LabelOverviewinstances that store counts (for classification-type data) or summary statistics (for continuous numerical/regression data).
- property label_properties: Optional[List[str]]#
Gets or sets the names of the property field(s) in each Feature of the label asset’s FeatureCollection that contains the classes (keywords from label:classes if the property defines classes). If labels are rasters, this should be None.
- property label_tasks: Optional[List[Union[pystac.extensions.label.LabelTask, str]]]#
Gets or set a list of tasks these labels apply to. Usually a subset of ‘regression’, ‘classification’, ‘detection’, or ‘segmentation’, but may be arbitrary values.
- property label_type: pystac.extensions.label.LabelType#
Gets or sets an Enum of either vector label type or raster label type.
- obj: pystac.item.Item#
- classmethod summaries(obj: pystac.collection.Collection, add_if_missing: bool = False) pystac.extensions.label.SummariesLabelExtension[source]#
Returns the extended summaries object for the given collection.
- class pystac.extensions.label.LabelExtensionHooks[source]#
Bases:
pystac.extensions.hooks.ExtensionHooks- get_object_links(so: pystac.stac_object.STACObject) Optional[List[Union[str, pystac.rel_type.RelType]]][source]#
- migrate(obj: Dict[str, Any], version: pystac.serialization.identify.STACVersionID, info: pystac.serialization.identify.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/label/v1.0.0/schema.json', 'label'}#
- stac_object_types = {STACObjectType.ITEM}#
- class pystac.extensions.label.LabelMethod(value)[source]#
Bases:
pystac.utils.StringEnumEnumerates recommended values for “label:methods” field.
- AUTOMATED = 'automated'#
- MANUAL = 'manual'#
- class pystac.extensions.label.LabelOverview(properties: Dict[str, Any])[source]#
Bases:
objectStores counts (for classification-type data) or summary statistics (for continuous numerical/regression data).
Use
LabelOverview.create()to create a new instance.- apply(property_key: Optional[str], counts: Optional[List[pystac.extensions.label.LabelCount]] = None, statistics: Optional[List[pystac.extensions.label.LabelStatistics]] = None) None[source]#
Sets the properties for this instance.
Either
countsorstatistics, or both, can be placed in an overview; at least one is required.- Parameters
property_key – The property key within the asset corresponding to class labels that these counts or statistics are referencing. If the label data is raster data, this should be None.
counts – Optional list of
LabelCountscontaining counts for categorical data.statistics – Optional list of
LabelStatisticscontaining statistics for regression/continuous numeric value data.
- property counts: Optional[List[pystac.extensions.label.LabelCount]]#
Gets or sets the list of
LabelCountscontaining counts for categorical data.
- classmethod create(property_key: Optional[str], counts: Optional[List[pystac.extensions.label.LabelCount]] = None, statistics: Optional[List[pystac.extensions.label.LabelStatistics]] = None) pystac.extensions.label.LabelOverview[source]#
Creates a new instance.
Either
countsorstatistics, or both, can be placed in an overview; at least one is required.- Parameters
property_key – The property key within the asset corresponding to class labels.
counts – Optional list of
LabelCountscontaining counts for categorical data.statistics – Optional list of
LabelStatisticscontaining statistics for regression/continuous numeric value data.
- merge_counts(other: pystac.extensions.label.LabelOverview) pystac.extensions.label.LabelOverview[source]#
Merges the counts associated with this overview with another overview. Creates a new instance.
- Parameters
other – The other LabelOverview to merge.
- Returns
A new LabelOverview with the counts merged. This will drop any statistics associated with either of the LabelOverviews.
- property property_key: Optional[str]#
Gets or sets the property key within the asset corresponding to class labels.
- property statistics: Optional[List[pystac.extensions.label.LabelStatistics]]#
Gets or sets the list of
LabelStatisticscontaining statistics for regression/continuous numeric value data.
- class pystac.extensions.label.LabelRelType(value)[source]#
Bases:
pystac.utils.StringEnumA list of rel types defined in the Label Extension.
See the Label Extension Links documentation for details.
- SOURCE = 'source'#
Used to indicate a link to the source item to which a label item applies.
- class pystac.extensions.label.LabelStatistics(properties: Dict[str, Any])[source]#
Bases:
objectContains statistics for regression/continuous numeric value data.
Use
LabelStatistics.create()to create a new instance.- apply(name: str, value: float) None[source]#
Sets the property values for this instance.
- Parameters
name – The name of the statistic being reported.
value – The value of the statistic
- classmethod create(name: str, value: float) pystac.extensions.label.LabelStatistics[source]#
Creates a new
LabelStatisticsinstance.- Parameters
name – The name of the statistic being reported.
value – The value of the statistic
- class pystac.extensions.label.LabelTask(value)[source]#
Bases:
pystac.utils.StringEnumEnumerates recommended values for “label:tasks” field.
- CLASSIFICATION = 'classification'#
- DETECTION = 'detection'#
- REGRESSION = 'regression'#
- SEGMENTATION = 'segmentation'#
- class pystac.extensions.label.LabelType(value)[source]#
Bases:
pystac.utils.StringEnumEnumerates valid label types (“raster” or “vector”).
- ALL = "['vector', 'raster']"#
Convenience attribute for checking if values are valid label types
- RASTER = 'raster'#
- VECTOR = 'vector'#
- class pystac.extensions.label.SummariesLabelExtension(collection: pystac.collection.Collection)[source]#
Bases:
pystac.extensions.base.SummariesExtensionA concrete implementation of
SummariesExtensionthat extends thesummariesfield of aCollectionto include properties defined in the Label Extension.- property label_classes: Optional[List[pystac.extensions.label.LabelClasses]]#
Get or sets the summary of
LabelExtension.label_classesvalues for this Collection.
- property label_methods: Optional[List[Union[pystac.extensions.label.LabelMethod, str]]]#
Get or sets the summary of
LabelExtension.label_methodsvalues for this Collection.
- property label_properties: Optional[List[str]]#
Get or sets the summary of
LabelExtension.label_propertiesvalues for this Collection.
- property label_tasks: Optional[List[Union[pystac.extensions.label.LabelTask, str]]]#
Get or sets the summary of
LabelExtension.label_tasksvalues for this Collection.
- property label_type: Optional[List[pystac.extensions.label.LabelType]]#
Get or sets the summary of
LabelExtension.label_typevalues for this Collection.
- summaries: pystac.summaries.Summaries#
The summaries for the
Collectionbeing extended.