API Reference¶
This API reference is auto-generated for the Python docstrings, and organized by the section of the STAC Spec they relate to, if related to a specific spec item.
Links¶
Catalogs, Collections and Items have links, which allow users to crawl catalogs.
Link¶
-
class
pystac.
Link
(rel, target, media_type=None, title=None, properties=None, link_type='ABSOLUTE')[source]¶ A link is connects a
STACObject
to another entity.The target of a link can be either another STACObject, or an HREF. When serialized, links always refer to the HREF of the target. Links are lazily deserialized - this is, when you read in a link, it does not automatically load in the STACObject that is the target (if the link is pointing to a STACObject). When a user is crawling through a catalog or when additional metadata is required, PySTAC uses the
Link.resolve_stac_object
method to load in and deserialize STACObjects. This mechanism is used within the PySTAC codebase and normally does not need to be considered by the user - ideally the lazy deserialization of STACObjects is transparent to clients of PySTAC.Parameters: - rel (str) – The relation of the link (e.g. ‘child’, ‘item’)
- target (str or STACObject) – The target of the link. If the link is unresolved, or the link is to something that is not a STACObject, the target is an HREF. If resolved, the target is a STACObject.
- media_type (str) – Optional description of the media type. Registered Media Types
are preferred. See
MediaType
for common media types. - title (str) – Optional title for this link.
- properties (dict) – Optional, additional properties for this link. This is used by extensions as a way to serialize and deserialize properties on link object JSON.
- link_type (str) – The link type, either relative or absolute. Use one of
LinkType
.
-
rel
¶ The relation of the link (e.g. ‘child’, ‘item’)
Type: str
-
target
¶ The target of the link. If the link is unresolved, or the link is to something that is not a STACObject, the target is an HREF. If resolved, the target is a STACObject.
Type: str or STACObject
-
media_type
¶ Optional description of the media type. Registered Media Types are preferred. See
MediaType
for common media types.Type: str or None
-
title
¶ Optional title for this link.
Type: str or None
-
properties
¶ Optional, additional properties for this link. This is used by extensions as a way to serialize and deserialize properties on link object JSON.
Type: dict or None
-
owner
¶ The owner of this link. The link will use its owner’s root catalog
ResolvedObjectCache
to resolve objects, and will create absolute HREFs from relative HREFs against the owner’s self HREF.Type: STACObject or None
-
static
child
(c, title=None, link_type='ABSOLUTE')[source]¶ Creates a link to a child Catalog or Collection.
-
clone
()[source]¶ Clones this link.
This makes a copy of all link information, but does not clone a STACObject if one is the target of this link.
Returns: The cloned link. Return type: Link
-
static
from_dict
(d)[source]¶ Deserializes a Link from a dict.
Parameters: d (dict) – The dict that represents the Link in JSON Returns: Link instance constructed from the dict. Return type: Link
-
get_absolute_href
()[source]¶ Gets the aboslute href for this link, if possible.
Returns: Returns this link’s HREF. It attempts to derive an absolute HREF from this link; however, if the link is relative, has no owner, and has an unresolved target, this will return a relative HREF. Return type: str
-
get_href
()[source]¶ Gets the HREF for this link.
Returns: Returns this link’s HREF. If the link type is LinkType.RELATIVE, and there is an owner of the link, then the HREF returned will be relative. In all other cases, this method will return an absolute HREF. Return type: str
-
is_resolved
()[source]¶ Determines if the link’s target is a resolved STACObject.
Returns: True if this link is resolved. Return type: bool
-
resolve_stac_object
(root=None)[source]¶ Resolves a STAC object from the HREF of this link, if the link is not already resolved.
Parameters: root (Catalog or Collection) – Optional root of the catalog for this link. If provided, the root’s resolved object cache is used to search for previously resolved instances of the STAC object.
-
set_owner
(owner)[source]¶ Sets the owner of this link.
Parameters: owner (STACObject) – The owner of this link.
LinkType¶
MediaType¶
-
class
pystac.
MediaType
[source]¶ A list of common media types that can be used in STAC Asset and Link metadata.
-
COG
= 'image/tiff; application=geotiff; profile=cloud-optimized'¶
-
GEOJSON
= 'application/geo+json'¶
-
GEOPACKAGE
= 'application/geopackage+sqlite3'¶
-
GEOTIFF
= 'image/tiff; application=geotiff'¶
-
HDF
= 'application/x-hdf'¶
-
HDF5
= 'application/x-hdf5'¶
-
JPEG
= 'image/jpeg'¶
-
JPEG2000
= 'image/jp2'¶
-
JSON
= 'application/json'¶
-
PNG
= 'image/png'¶
-
TEXT
= 'text/plain'¶
-
TIFF
= 'image/tiff'¶
-
XML
= 'application/xml'¶
-
IO¶
STAC_IO¶
STAC_IO is the utility mechanism that PySTAC uses for reading and writing. Users of PySTAC can hook into PySTAC by overriding members to utilize their own IO methods.
-
class
pystac.
STAC_IO
[source]¶ Methods used to read and save STAC json. Allows users of the library to set their own methods (e.g. for reading and writing from cloud storage)
-
default_write_text_method
(txt)[source]¶ Default method for writing text. Only handles local file paths.
-
classmethod
read_json
(uri)[source]¶ Read a dict from the given URI.
Parameters: uri (str) – The URI from which to read. Returns: A dict representation of the JSON contained in the file at the given uri. Return type: dict Note
This method uses the
STAC_IO.read_text_method
. If you want to modify the behavior of STAC_IO in order to enable additional URI types, replace that member with your own implementation.
-
classmethod
read_stac_object
(uri, root=None)[source]¶ Read a STACObject from a JSON file at the given URI.
Parameters: - uri (str) – The URI from which to read.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The deserialized STACObject from the serialized JSON contained in the file at the given uri.
Return type: Note
This method uses the
STAC_IO.read_text_method
. If you want to modify the behavior of STAC_IO in order to enable additional URI types, replace that member with your own implementation.
-
classmethod
read_text
(uri)[source]¶ Read text from the given URI.
Parameters: uri (str) – The URI from which to read text. Returns: The text contained in the file at the location specified by the uri. Return type: str Note
This method uses the
STAC_IO.read_text_method
. If you want to modify the behavior of STAC_IO in order to enable additional URI types, replace that member with your own implementation.
-
read_text_method
()¶ Users of PySTAC can replace the read_text_method in order to expand the ability of PySTAC to read different file systems. For example, a client of the library might replace this class member in it’s own __init__.py with a method that can read from cloud storage.
-
classmethod
save_json
(uri, json_dict)[source]¶ Write a dict to the given URI as JSON.
Parameters: - uri (str) – The URI of the file to write the text to.
- json_dict (dict) – The JSON dict to write.
Note
This method uses the
STAC_IO.write_text_method
. If you want to modify the behavior of STAC_IO in order to enable additional URI types, replace that member with your own implementation.
-
stac_object_from_dict
(href=None, root=None)¶ Determines how to deserialize a dictionary into a STAC object.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Note: This is used internally in STAC_IO to deserialize STAC Objects. It is in the top level __init__ in order to avoid circular dependencies.
-
classmethod
write_text
(uri, txt)[source]¶ Write the given text to a file at the given URI.
Parameters: - uri (str) – The URI of the file to write the text to.
- txt (str) – The text to write.
Note
This method uses the
STAC_IO.write_text_method
. If you want to modify the behavior of STAC_IO in order to enable additional URI types, replace that member with your own implementation.
-
write_text_method
(txt)¶ Users of PySTAC can replace the writte_text_method in order to expand the ability of PySTAC to write to different file systems. For example, a client of the library might replace this class member in it’s own __init__.py with a method that can read from cloud storage.
-
Errors¶
Catalog Spec¶
These classes are representations of the Catalog Spec.
Catalog¶
-
class
pystac.
Catalog
(id, description, title=None, stac_extensions=None, href=None)[source]¶ Bases:
pystac.stac_object.STACObject
A PySTAC Catalog represents a STAC catalog in memory.
A Catalog is a
STACObject
that may contain children, which are instances ofCatalog
orCollection
, as well asItem
s.Parameters: - id (str) – Identifier for the catalog. Must be unique within the STAC.
- description (str) – Detailed multi-line description to fully explain the catalog. CommonMark 0.28 syntax MAY be used for rich text representation.
- title (str or None) – Optional short descriptive one-line title for the catalog.
- stac_extensions (List[str]) – Optional list of extensions the Catalog implements.
- href (str or None) – Optional HREF for this catalog, which be set as the catalog’s self link’s HREF.
-
id
¶ Identifier for the catalog.
Type: str
-
description
¶ Detailed multi-line description to fully explain the catalog.
Type: str
-
title
¶ Optional short descriptive one-line title for the catalog.
Type: str or None
-
stac_extensions
¶ Optional list of extensions the Catalog implements.
Type: List[str] or None
-
DEFAULT_FILE_NAME
= 'catalog.json'¶ Default file name that will be given to this STAC object in a cononical format.
-
add_child
(child, title=None)[source]¶ Adds a link to a child
Catalog
orCollection
. This method will set the child’s parent to this object, and its root to this Catalog’s root.Parameters: - child (Catalog or Collection) – The child to add.
- title (str) – Optional title to give to the
Link
-
add_item
(item, title=None)[source]¶ Adds a link to an
Item
. This method will set the item’s parent to this object, and its root to this Catalog’s root.Parameters:
-
add_items
(items)[source]¶ Adds links to multiple
Item
s. This method will set each item’s parent to this object, and their root to this Catalog’s root.Parameters: items (Iterable[Item]) – The items to add.
-
clear_children
()[source]¶ Removes all children from this catalog.
Returns: Returns self
Return type: Catalog
-
clear_items
()[source]¶ Removes all items from this catalog.
Returns: Returns self
Return type: Catalog
-
clone
()[source]¶ Clones this object.
Cloning an object will make a copy of all properties and links of the object; however, it will not make copies of the targets of links (i.e. it is not a deep copy). To copy a STACObject fully, with all linked elements also copied, use
STACObject.full_copy
.Returns: The clone of this object. Return type: STACObject
-
describe
(include_hrefs=False, _indent=0)[source]¶ Prints out information about this Catalog and all contained STACObjects.
Parameters: include_hrefs (bool) – HREF along with the object ID.
-
classmethod
from_dict
(d, href=None, root=None)[source]¶ Parses this STACObject from the passed in dictionary.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The STACObject parsed from this dict.
Return type:
-
fully_resolve
()[source]¶ Ensure all STACObjects linked to by this STACObject are resolved. This is important for operations such as changing HREFs.
This method mutates the entire catalog tree.
-
get_all_items
()[source]¶ Get all items from this catalog and all subcatalogs. Will traverse any subcatalogs recursively.
Returns: - All items that belong to this catalog, and all
- catalogs or collections connected to this catalog through child links.
Return type: Generator[Item]
-
get_child
(id, recursive=False)[source]¶ Gets the child of this catalog with the given ID, if it exists.
Parameters: - id (str) – The ID of the child to find.
- recursive (bool) – If True, search this catalog and all children for the item; otherwise, only search the children of this catalog. Defaults to False.
Returns: The item with the given ID, or None if not found.
Return type: Item or None
-
get_child_links
()[source]¶ Return all child links of this catalog.
Returns: List of links of this catalog with rel == 'child'
Return type: List[Link]
-
get_children
()[source]¶ Return all children of this catalog.
Returns: Generator of children who’s parent is this catalog. Return type: Generator[Catalog or Collection]
-
get_item
(id, recursive=False)[source]¶ Returns an item with a given ID.
Parameters: - id (str) – The ID of the item to find.
- recursive (bool) – If True, search this catalog and all children for the item; otherwise, only search the items of this catalog. Defaults to False.
Returns: The item with the given ID, or None if not found.
Return type: Item or None
-
get_item_links
()[source]¶ Return all item links of this catalog.
Returns: List of links of this catalog with rel == 'item'
Return type: List[Link]
-
get_items
()[source]¶ Return all items of this catalog.
Returns: Generator of items who’s parent is this catalog. Return type: Generator[Item]
-
make_all_asset_hrefs_absolute
()[source]¶ Makes all the HREFs of assets belonging to items in this catalog and all children to be absoluet, recursively.
-
make_all_asset_hrefs_relative
()[source]¶ Makes all the HREFs of assets belonging to items in this catalog and all children to be relative, recursively.
-
make_all_links_absolute
()[source]¶ Makes all the links of this catalog and all children and item to be absolute, recursively
-
make_all_links_relative
()[source]¶ Makes all the links of this catalog and all children and item to be relative, recursively
-
map_assets
(asset_mapper)[source]¶ Creates a copy of a catalog, with each Asset for each Item passed through the asset_mapper function.
Parameters: asset_mapper (Callable) – A function that takes in an key and an Asset, and returns either an Asset, a (key, Asset), or a dictionary of Assets with unique keys. The Asset that is passed into the item_mapper is a copy, so the method can mutate it safetly. Returns: A full copy of this catalog, with assets manipulated according to the asset_mapper function. Return type: Catalog
-
map_items
(item_mapper)[source]¶ Creates a copy of a catalog, with each item passed through the item_mapper function.
Parameters: item_mapper (Callable) – A function that takes in an item, and returns either an item or list of items. The item that is passed into the item_mapper is a copy, so the method can mutate it safetly. Returns: A full copy of this catalog, with items manipulated according to the item_mapper function. Return type: Catalog
-
normalize_and_save
(root_href, catalog_type)[source]¶ Normalizes link HREFs to the given root_href, and saves the catalog with the given catalog_type.
This is a convenience method that simply calls
Catalog.normalize_hrefs
andCatalog.save
in sequence.Parameters: - root_href (str) – The absolute HREF that all links will be normalized against.
- catalog_type (str) – The catalog type that dictates the structure of
the catalog to save. Use a member of
CatalogType
.
-
normalize_hrefs
(root_href)[source]¶ Normalize HREFs will regenerate all link HREFs based on an absolute root_href and the canonical catalog layout as specified in the STAC specification’s best practices.
This method mutates the entire catalog tree.
Parameters: root_href (str) – The absolute HREF that all links will be normalized against. - See:
- STAC best practices document for the canonical layout of a STAC.
-
remove_child
(child_id)[source]¶ Removes an child from this catalog.
Parameters: child_id (str) – The ID of the child to remove.
-
remove_item
(item_id)[source]¶ Removes an item from this catalog.
Parameters: item_id (str) – The ID of the item to remove.
-
save
(catalog_type)[source]¶ Save this catalog and all it’s children/item to files determined by the object’s self link HREF.
Parameters: catalog_type (str) – The catalog type that dictates the structure of the catalog to save. Use a member of CatalogType
.Note
If the catalog type is
CatalogType.ABSOLUTE_PUBLISHED
, all self links will be included, and link type will be set to ABSOLUTE. If the catalog type isCatalogType.RELATIVE_PUBLISHED
, this catalog’s self link will be included, but no child catalog will have self links. Link types will be set to RELATIVE. If the catalog type isCatalogType.SELF_CONTAINED
, no self links will be included. Link types will be set to RELATIVE.
-
set_root
(root, link_type='ABSOLUTE')[source]¶ Sets the root
Catalog
orCollection
for this object.Parameters: - root (Catalog, Collection or None) – The root object to set. Passing in None will clear the root.
- link_type (str) – The link type (see
LinkType
)
-
to_dict
(include_self_link=True)[source]¶ Generate a dictionary representing the JSON of this serialized object.
Parameters: include_self_link (bool) – If True, the dict will contain a self link to this object. If False, the self link will be omitted. Returns: A serializion of the object that can be written out as JSON. Return type: dict
-
walk
()[source]¶ Walks through children and items of catalogs.
For each catalog in the STAC’s tree rooted at this catalog (including this catalog itself), it yields a 3-tuple (root, subcatalogs, items). The root in that 3-tuple refers to the current catalog being walked, the subcatalogs are any catalogs or collections for which the root is a parent, and items represents any items that have the root as a parent.
This has similar functionality to Python’s
os.walk()
.Returns: A generator that yields a 3-tuple (parent_catalog, children, items). Return type: Generator[(Catalog, Generator[Catalog], Generator[Item])]
CatalogType¶
-
class
pystac.
CatalogType
[source]¶ -
ABSOLUTE_PUBLISHED
= 'ABSOLUTE_PUBLISHED'¶ Absolute Published Catalog is a catalog that uses absolute links for everything, both in the links objects and in the asset hrefs.
-
RELATIVE_PUBLISHED
= 'RELATIVE_PUBLISHED'¶ Relative Published Catalog is a catalog that uses relative links for everything, but includes an absolute self link at the root catalog, to identify its online location.
-
SELF_CONTAINED
= 'SELF_CONTAINED'¶ A ‘self-contained catalog’ is one that is designed for portability. Users may want to download a catalog from online and be able to use it on their local computer, so all links need to be relative.
-
Collection Spec¶
These classes are representations of the Collection Spec.
Collection¶
-
class
pystac.
Collection
(id, description, extent, title=None, stac_extensions=None, href=None, license='proprietary', keywords=None, version=None, providers=None, properties=None, summaries=None)[source]¶ Bases:
pystac.catalog.Catalog
A Collection extends the Catalog spec with additional metadata that helps enable discovery.
Parameters: - id (str) – Identifier for the collection. Must be unique within the STAC.
- description (str) –
Detailed multi-line description to fully explain the collection. CommonMark 0.28 syntax MAY be used for rich text representation.
- extent (Extent) – Spatial and temporal extents that describe the bounds of all items contained within this Collection.
- title (str or None) – Optional short descriptive one-line title for the collection.
- stac_extensions (List[str]) – Optional list of extensions the Collection implements.
- href (str or None) – Optional HREF for this collection, which be set as the collection’s self link’s HREF.
- license (str) – Collection’s license(s) as a SPDX License identifier or expression. Defaults to ‘proprietary’.
- keywords (List[str]) – Optional list of keywords describing the collection.
- version (str) – Optional version of the Collection.
- providers (List[Provider]) – Optional list of providers of this Collection.
- properties (dict) – Optional dict of common fields across referenced items.
- summaries (dict) – An optional map of property summaries, either a set of values or statistics such as a range.
-
id
¶ Identifier for the collection.
Type: str
-
description
¶ Detailed multi-line description to fully explain the collection.
Type: str
-
extent
¶ Spatial and temporal extents that describe the bounds of all items contained within this Collection.
Type: Extent
-
title
¶ Optional short descriptive one-line title for the collection.
Type: str or None
-
stac_extensions
¶ Optional list of extensions the Collection implements.
Type: List[str]
-
keywords
¶ Optional list of keywords describing the collection.
Type: List[str] or None
-
version
¶ Optional version of the Collection.
Type: str or None
-
properties
¶ Optional dict of common fields across referenced items.
Type: dict or None
-
summaries
¶ An optional map of property summaries, either a set of values or statistics such as a range.
Type: dict or None
-
links
¶ A list of
Link
objects representing all links associated with this Collection.Type: List[Link]
-
DEFAULT_FILE_NAME
= 'collection.json'¶ Default file name that will be given to this STAC object in a cononical format.
-
add_item
(item, title=None)[source]¶ Adds a link to an
Item
. This method will set the item’s parent to this object, and its root to this Catalog’s root.Parameters:
-
clone
()[source]¶ Clones this object.
Cloning an object will make a copy of all properties and links of the object; however, it will not make copies of the targets of links (i.e. it is not a deep copy). To copy a STACObject fully, with all linked elements also copied, use
STACObject.full_copy
.Returns: The clone of this object. Return type: STACObject
-
classmethod
from_dict
(d, href=None, root=None)[source]¶ Parses this STACObject from the passed in dictionary.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The STACObject parsed from this dict.
Return type:
-
set_self_href
(href)[source]¶ Sets the absolute HREF that is represented by the
rel == 'self'
Link
.Parameters: str – The absolute HREF of this object. If the given HREF is not absolute, it will be transformed to an absolute HREF based on the current working directory. Note
Overridden for collections so that the root’s ResolutionObjectCache can properly update the HREF cache.
-
to_dict
(include_self_link=True)[source]¶ Generate a dictionary representing the JSON of this serialized object.
Parameters: include_self_link (bool) – If True, the dict will contain a self link to this object. If False, the self link will be omitted. Returns: A serializion of the object that can be written out as JSON. Return type: dict
Extent¶
-
class
pystac.
Extent
(spatial, temporal)[source]¶ Describes the spatio-temporal extents of a Collection.
Parameters: - spatial (SpatialExtent) – Potential spatial extent covered by the collection.
- temporal (TemporalExtent) – Potential temporal extent covered by the collection.
-
spatial
¶ Potential spatial extent covered by the collection.
Type: SpatialExtent
-
temporal
¶ Potential temporal extent covered by the collection.
Type: TemporalExtent
SpatialExtent¶
-
class
pystac.
SpatialExtent
(bboxes)[source]¶ Describes the spatial extent of a Collection.
Parameters: bboxes (List[List[float]]) – A list of bboxes that represent the spatial extent of the collection. Each bbox can be 2D or 3D. The length of the bbox array must be 2*n where n is the number of dimensions. For example, a 2D Collection with only one bbox would be [[xmin, ymin, xmax, ymax]] -
bboxes
¶ A list of bboxes that represent the spatial extent of the collection. Each bbox can be 2D or 3D. The length of the bbox array must be 2*n where n is the number of dimensions. For example, a 2D Collection with only one bbox would be [[xmin, ymin, xmax, ymax]]
Type: List[List[float]]
-
clone
()[source]¶ Clones this object.
Returns: The clone of this object. Return type: SpatialExtent
-
static
from_coordinates
(coordinates)[source]¶ Constructs a SpatialExtent from a set of coordinates.
This method will only produce a single bbox that covers all points in the coordinate set.
Parameters: coordinates (List[float]) – Coordinates to derive the bbox from. Returns: A SpatialExtent with a single bbox that covers the given coordinates. Return type: SpatialExtent
-
static
from_dict
(d)[source]¶ Constructs an SpatialExtent from a dict.
Returns: The SpatialExtent deserialized from the JSON dict. Return type: SpatialExtent
-
TemporalExtent¶
-
class
pystac.
TemporalExtent
(intervals)[source]¶ Describes the temporal extent of a Collection.
Parameters: - intervals (List[List[datetime]]) – A list of two datetimes wrapped in a list,
- the temporal extent of a Collection. Open date ranges are supported (representing) –
- setting either the start (by) –
- element of the interval) to None. (second) –
-
intervals
¶ A list of two datetimes wrapped in a list,
Type: List[List[datetime]]
-
representing the temporal extent of a Collection. Open date ranges are represented
-
by either the start
Type: the first element of the interval
-
second element of the interval) being None.
Note
Datetimes are required to be in UTC.
-
clone
()[source]¶ Clones this object.
Returns: The clone of this object. Return type: TemporalExtent
-
static
from_dict
(d)[source]¶ Constructs an TemporalExtent from a dict.
Returns: The TemporalExtent deserialized from the JSON dict. Return type: TemporalExtent
-
static
from_now
()[source]¶ Constructs an TemporalExtent with a single open interval that has the start time as the current time.
Returns: The resulting TemporalExtent. Return type: TemporalExtent
Provider¶
-
class
pystac.
Provider
(name, description=None, roles=None, url=None)[source]¶ Provides information about a provider of STAC data. A provider is any of the organizations that captured or processed the content of the collection and therefore influenced the data offered by this collection. May also include information about the final storage provider hosting the data.
Parameters: - name (str) – The name of the organization or the individual.
- description (str) – Optional multi-line description to add further provider information such as processing details for processors and producers, hosting details for hosts or basic contact information.
- roles (List[str]) – Optional roles of the provider. Any of licensor, producer, processor or host.
- url (str) – Optional homepage on which the provider describes the dataset and publishes contact information.
-
name
¶ The name of the organization or the individual.
Type: str
-
description
¶ Optional multi-line description to add further provider information such as processing details for processors and producers, hosting details for hosts or basic contact information.
Type: str
-
roles
¶ Optional roles of the provider. Any of licensor, producer, processor or host.
Type: List[str]
-
url
¶ Optional homepage on which the provider describes the dataset and publishes contact information.
Type: str
-
static
from_dict
(d)[source]¶ Constructs an Provider from a dict.
Returns: The Provider deserialized from the JSON dict. Return type: TemporalExtent
Item Spec¶
These classes are representations of the Item Spec.
Item¶
-
class
pystac.
Item
(id, geometry, bbox, datetime, properties, stac_extensions=None, href=None, collection=None)[source]¶ Bases:
pystac.stac_object.STACObject
An Item is the core granular entity in a STAC, containing the core metadata that enables any client to search or crawl online catalogs of spatial ‘assets’ - satellite imagery, derived data, DEM’s, etc.
Parameters: - id (str) – Provider identifier. Must be unique within the STAC.
- geometry (dict) – Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 (GeoJSON).
- bbox (List[float]) – Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array must be 2*n where n is the number of dimensions.
- datetime (Datetime) – Datetime associated with this item.
- properties (dict) – A dictionary of additional metadata for the item.
- stac_extensions (List[str]) – Optional list of extensions the Item implements.
- href (str or None) – Optional HREF for this item, which be set as the item’s self link’s HREF.
- collection (Collection or str) – The Collection or Collection ID that this item belongs to.
-
id
¶ Provider identifier. Unique within the STAC.
Type: str
-
geometry
¶ Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 (GeoJSON).
Type: dict
-
bbox
¶ Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array is 2*n where n is the number of dimensions.
Type: List[float]
-
datetime
¶ Datetime associated with this item.
Type: Datetime
-
properties
¶ A dictionary of additional metadata for the item.
Type: dict
-
stac_extensions
¶ Optional list of extensions the Item implements.
Type: List[str] or None
-
collection
¶ Collection that this item is a part of.
Type: Collection or None
-
links
¶ A list of
Link
objects representing all links associated with this STACObject.Type: List[Link]
-
assets
¶ Dictionary of asset objects that can be downloaded, each with a unique key.
Type: Dict[str, Asset]
-
collection_id
¶ The Collection ID that this item belongs to, if any.
Type: str or None
-
add_asset
(key, asset)[source]¶ Adds an Asset to this item.
Parameters: - key (str) – The unique key of this asset.
- asset (Asset) – The Asset to add.
-
clone
()[source]¶ Clones this object.
Cloning an object will make a copy of all properties and links of the object; however, it will not make copies of the targets of links (i.e. it is not a deep copy). To copy a STACObject fully, with all linked elements also copied, use
STACObject.full_copy
.Returns: The clone of this object. Return type: STACObject
-
classmethod
from_dict
(d, href=None, root=None)[source]¶ Parses this STACObject from the passed in dictionary.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The STACObject parsed from this dict.
Return type:
-
fully_resolve
()[source]¶ Ensure all STACObjects linked to by this STACObject are resolved. This is important for operations such as changing HREFs.
This method mutates the entire catalog tree.
-
get_assets
()[source]¶ Get this item’s assets.
Returns: A copy of the dictonary of this item’s assets. Return type: Dict[str, Asset]
-
make_asset_hrefs_absolute
()[source]¶ Modify each asset’s HREF to be absolute.
Any asset HREFs that are relative will be modified to absolute based on this item’s self HREF.
Returns: self Return type: Item
-
make_asset_hrefs_relative
()[source]¶ Modify each asset’s HREF to be relative to this item’s self HREF.
Returns: self Return type: Item
-
normalize_hrefs
(root_href)[source]¶ Normalize HREFs will regenerate all link HREFs based on an absolute root_href and the canonical catalog layout as specified in the STAC specification’s best practices.
This method mutates the entire catalog tree.
Parameters: root_href (str) – The absolute HREF that all links will be normalized against. - See:
- STAC best practices document for the canonical layout of a STAC.
-
set_collection
(collection, link_type=None)[source]¶ Set the collection of this item.
This method will replace any existing Collection link and attribute for this item.
Parameters: - collection (Collection) – The collection to set as this item’s collection.
- link_type (str) – the link type to use for the collection link.
One of
LinkType
.
Returns: self
Return type:
-
to_dict
(include_self_link=True)[source]¶ Generate a dictionary representing the JSON of this serialized object.
Parameters: include_self_link (bool) – If True, the dict will contain a self link to this object. If False, the self link will be omitted. Returns: A serializion of the object that can be written out as JSON. Return type: dict
Asset¶
-
class
pystac.
Asset
(href, title=None, media_type=None, properties=None)[source]¶ An object that contains a link to data associated with the Item that can be downloaded or streamed.
Parameters: - href (str) – Link to the asset object. Relative and absolute links are both allowed.
- title (str) – Optional displayed title for clients and users.
- media_type (str) – Optional description of the media type. Registered Media Types
are preferred. See
MediaType
for common media types. - properties (dict) – Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON.
-
href
¶ Link to the asset object. Relative and absolute links are both allowed.
Type: str
-
title
¶ Optional displayed title for clients and users.
Type: str
-
media_type
¶ Optional description of the media type. Registered Media Types are preferred. See
MediaType
for common media types.Type: str
-
properties
¶ Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON.
Type: dict
-
static
from_dict
(d)[source]¶ Constructs an Asset from a dict.
Returns: The Asset deserialized from the JSON dict. Return type: Asset
-
get_absolute_href
()[source]¶ Gets the absolute href for this asset, if possible.
If this Asset has no associated Item, this will return whatever the href is (as it cannot determine the absolute path, if the asset href is relative).
Returns: The absolute HREF of this asset, or a relative HREF is an abslolute HREF cannot be determined. Return type: str
ItemCollection¶
-
class
pystac.
ItemCollection
(features=None)[source]¶ A GeoJSON FeatureCollection that is augmented with foreign members relevant to a STAC entity.
Parameters: features (List[Item]) – Optional initial list of items contained by this ItemCollection. -
links
¶ A list of
Link
objects representing all links associated with this ItemCollection.Type: List[Link]
-
add_item
(item)[source]¶ Adds an Item to this ItemCollection.
Parameters: item (Item) – The item to add.
-
add_items
(items)[source]¶ Adds Items to this ItemCollection.
Parameters: items (Iterable[Item]) – The items to add.
-
static
from_dict
(d)[source]¶ Constructs an ItemCollection from a dict.
Returns: The ItemCollection deserialized from the JSON dict. Return type: ItemCollection
-
static
from_file
(href)[source]¶ Reads an ItemCollection from a file.
Parameters: href (str) – The HREF to read the item from. Returns: ItemCollection that was read from the given file. Return type: ItemCollection
-
get_items
()[source]¶ Gets all the items associated with this ItemCollection.
Returns: The Items of this ItemCollection Return type: List[Item]
-
save
(href=None, include_self_link=True)[source]¶ Saves this ItemCollection.
Parameters: - href (str) – The HREF to save the ItemCollection to. If None,
will save to the currently set
self
link. If supplied, will set this href to the ItemCollection’s self link. - include_self_link (bool) – If True, will include the self link in the set of links of the saved JSON.
- href (str) – The HREF to save the ItemCollection to. If None,
will save to the currently set
-
to_dict
(include_self_link=False)[source]¶ Generate a dictionary representing the JSON of this ItemCollection.
Parameters: include_self_link (bool) – If True, writes the ItemCollection’s self link. Defaults to False. Returns: A serializion of the ItemCollection that can be written out as JSON. Return type: dict
-
EO Extension¶
These classes are representations of the EO Extension Spec.
EOItem¶
-
class
pystac.
EOItem
(id, geometry, bbox, datetime, properties, gsd, platform, instrument, bands, constellation=None, epsg=None, cloud_cover=None, off_nadir=None, azimuth=None, sun_azimuth=None, sun_elevation=None, stac_extensions=None, href=None, collection=None)[source]¶ Bases:
pystac.item.Item
EOItem represents a snapshot of the earth for a single date and time.
Parameters: - id (str) – Provider identifier. Must be unique within the STAC.
- geometry (dict) –
Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 (GeoJSON).
- bbox (List[float]) – Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array must be 2*n where n is the number of dimensions.
- datetime (Datetime) – Datetime associated with this item.
- properties (dict) – A dictionary of additional metadata for the item.
- gsd (float) – Ground Sample Distance at the sensor.
- platform (str) – Unique name of the specific platform to which the instrument is attached.
- instrument (str) – Name of instrument or sensor used (e.g., MODIS, ASTER, OLI, Canon F-1).
- bands (List[Band]) – This is a list of
Band
objects that represent the available bands. - constellation (str) – Optional name of the constellation to which the platform belongs.
- epsg (int) – Optional EPSG code.
- cloud_cover (float) – Optional estimate of cloud cover as a percentage (0-100) of the entire scene. If not available the field should not be provided.
- off_nadir (float) – Optional viewing angle. The angle from the sensor between nadir (straight down) and the scene center. Measured in degrees (0-90).
- azimuth (float) – Optional viewing azimuth angle. The angle measured from the sub-satellite point (point on the ground below the platform) between the scene center and true north. Measured clockwise from north in degrees (0-360).
- sun_azimuth (float) – Optional sun azimuth angle. From the scene center point on the ground, this is the angle between truth north and the sun. Measured clockwise in degrees (0-360).
- sun_elevation (float) – Optional sun elevation angle. The angle from the tangent of the scene center point to the sun. Measured from the horizon in degrees (0-90).
- stac_extensions (List[str]) – Optional list of extensions the Item implements.
- href (str or None) – Optional HREF for this item, which be set as the item’s self link’s HREF.
- collection (Collection or str) – The Collection or Collection ID that this item belongs to.
-
id
¶ Provider identifier. Unique within the STAC.
Type: str
-
geometry
¶ Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 (GeoJSON).
Type: dict
-
bbox
¶ Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array is 2*n where n is the number of dimensions.
Type: List[float]
-
datetime
¶ Datetime associated with this item.
Type: Datetime
-
properties
¶ A dictionary of additional metadata for the item.
Type: dict
-
stac_extensions
¶ Optional list of extensions the Item implements.
Type: List[str] or None
-
collection
¶ Collection that this item is a part of.
Type: Collection or None
-
gsd
¶ Ground Sample Distance at the sensor.
Type: float
-
platform
¶ Unique name of the specific platform to which the instrument is attached.
Type: str
-
instrument
¶ Name of instrument or sensor used (e.g., MODIS, ASTER, OLI, Canon F-1).
Type: str
-
constellation
¶ Name of the constellation to which the platform belongs.
Type: str or None
-
cloud_cover
¶ Estimate of cloud cover as a percentage (0-100) of the entire scene. If not available the field should not be provided.
Type: float or None
-
off_nadir
¶ Viewing angle. The angle from the sensor between nadir (straight down) and the scene center. Measured in degrees (0-90).
Type: float or None
-
azimuth
¶ Viewing azimuth angle. The angle measured from the sub-satellite point (point on the ground below the platform) between the scene center and true north. Measured clockwise from north in degrees (0-360).
Type: float or None
-
sun_azimuth
¶ Sun azimuth angle. From the scene center point on the ground, this is the angle between truth north and the sun. Measured clockwise in degrees (0-360).
Type: float or None
-
sun_elevation
¶ Sun elevation angle. The angle from the tangent of the scene center point to the sun. Measured from the horizon in degrees (0-90).
Type: float or None
-
links
¶ A list of
Link
objects representing all links associated with this STACObject.Type: List[Link]
-
assets
¶ Dictionary of asset objects that can be downloaded, each with a unique key.
Type: Dict[str, Asset]
-
collection_id
¶ The Collection ID that this item belongs to, if any.
Type: str or None
-
add_asset
(key, asset)[source]¶ Adds an Asset to this item. If this Asset contains band information in it’s properties, converts the Asset to an
EOAsset
.Parameters: - key (str) – The unique key of this asset.
- asset (Asset) – The Asset to add.
-
clone
()[source]¶ Clones this object.
Cloning an object will make a copy of all properties and links of the object; however, it will not make copies of the targets of links (i.e. it is not a deep copy). To copy a STACObject fully, with all linked elements also copied, use
STACObject.full_copy
.Returns: The clone of this object. Return type: STACObject
-
classmethod
from_dict
(d, href=None, root=None)[source]¶ Parses this STACObject from the passed in dictionary.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The STACObject parsed from this dict.
Return type:
-
classmethod
from_item
(item)[source]¶ Creates an EOItem from an Item.
Parameters: item (Item) – The Item to create an EOItem from. Returns: - A new EOItem from item. If the item
- item is already an EOItem, simply returns a clone of item.
Return type: EOItem
-
get_eo_assets
()[source]¶ Gets the assets of this item that are
EOAsset
s.Returns: This item’s assets, subestted to only include EOAssets. Return type: Dict[EOAsset]
-
to_dict
(include_self_link=True)[source]¶ Generate a dictionary representing the JSON of this serialized object.
Parameters: include_self_link (bool) – If True, the dict will contain a self link to this object. If False, the self link will be omitted. Returns: A serializion of the object that can be written out as JSON. Return type: dict
EOAsset¶
-
class
pystac.
EOAsset
(href, bands, title=None, media_type=None, properties=None)[source]¶ Bases:
pystac.item.Asset
An Asset that contains band information via a bands property that is an array of 0 based indexes to the correct band object on the owning EOItem.
Parameters: - href (str) – Link to the asset object. Relative and absolute links are both allowed.
- bands (List[int]) – Lists the band names available in the asset.
- title (str) – Optional displayed title for clients and users.
- media_type (str) – Optional description of the media type. Registered Media Types
are preferred. See
MediaType
for common media types. - properties (dict) – Optional, additional properties for this asset.
-
href
¶ Link to the asset object. Relative and absolute links are both allowed.
Type: str
-
bands
¶ Lists the band names available in the asset.
Type: List[int]
-
title
¶ Optional displayed title for clients and users.
Type: str
-
media_type
¶ Optional description of the media type. Registered Media Types are preferred. See
MediaType
for common media types.Type: str
-
properties
¶ Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON.
Type: dict
-
classmethod
from_asset
(asset)[source]¶ Constructs an EOAsset from an Asset.
Returns: The EOAsset created from this asset. If the asset is already an EOAsset, will return a clone.
Return type: Raises: STACError
– Raised if no band information is in the properties- of asset.
-
static
from_dict
(d)[source]¶ Constructs an EOAsset from a dict.
Returns: The EOAsset deserialized from the JSON dict. Return type: EOAsset
-
get_bands
()[source]¶ Returns the band information from the owning item for the bands referenced by this EOAsset.
Returns: The band information from the owning item for each band that is represented by this EOAsset’s
bands
.Return type: List[Band]
Raises: STACError
– Raised if no band information is in the properties- of asset.
Band¶
-
class
pystac.
Band
(name=None, common_name=None, description=None, gsd=None, accuracy=None, center_wavelength=None, full_width_half_max=None)[source]¶ Represents Band information attached to an EOItem.
Parameters: - name (str) – The name of the band (e.g., “B01”, “B02”, “B1”, “B5”, “QA”).
- common_name (str) – The name commonly used to refer to the band to make it easier to search for bands across instruments. See the list of accepted common names.
- description (str) – Description to fully explain the band.
- gsd (float) – Ground Sample Distance, the nominal distance between pixel centers available, in meters. Defaults to the EOItems’ eo:gsd if not provided.
- accuracy (float) – The expected error between the measured location and the true location of a pixel, in meters on the ground.
- center_wavelength (float) – The center wavelength of the band, in micrometers (μm).
- full_width_half_max (float) – Full width at half maximum (FWHM). The width of the band, as measured at half the maximum transmission, in micrometers (μm).
-
name
¶ The name of the band (e.g., “B01”, “B02”, “B1”, “B5”, “QA”).
Type: str
-
common_name
¶ The name commonly used to refer to the band to make it easier to search for bands across instruments. See the list of accepted common names.
Type: str
-
description
¶ Description to fully explain the band.
Type: str
-
gsd
¶ Ground Sample Distance, the nominal distance between pixel centers available, in meters. Defaults to the EOItems’ eo:gsd if not provided.
Type: float
-
accuracy
¶ The expected error between the measured location and the true location of a pixel, in meters on the ground.
Type: float
-
center_wavelength
¶ The center wavelength of the band, in micrometers (μm).
Type: float
-
full_width_half_max
¶ Full width at half maximum (FWHM). The width of the band, as measured at half the maximum transmission, in micrometers (μm).
Type: float
-
static
band_description
(common_name)[source]¶ Returns a description of the band for one with a common name.
Parameters: common_name (str) – The common band name. Must be one of the list of accepted common names.
Returns: If a recognized common name, returns a description including the band range. Otherwise returns None. Return type: str or None
-
static
band_range
(common_name)[source]¶ Gets the band range for a common band name.
Parameters: common_name (str) – The common band name. Must be one of the list of accepted common names.
Returns: The band range for this name as (min, max), or None if this is not a recognized common name. Return type: Tuple[float, float] or None
Label Extension¶
These classes are representations of the Label Extension Spec.
LabelItem¶
-
class
pystac.
LabelItem
(id, geometry, bbox, datetime, properties, label_description, label_type, label_properties=None, label_classes=None, label_tasks=None, label_methods=None, label_overviews=None, stac_extensions=None, href=None, collection=None)[source]¶ Bases:
pystac.item.Item
A Label Item represents a polygon, set of polygons, or raster data defining labels and label metadata and should be part of a Collection.
Parameters: - id (str) – Provider identifier. Must be unique within the STAC.
- geometry (dict) –
Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 (GeoJSON).
- bbox (List[float]) – Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array must be 2*n where n is the number of dimensions.
- datetime (Datetime) – Datetime associated with this item.
- properties (dict) – A dictionary of additional metadata for the item.
- label_desecription (str) – A description of the label, how it was created, and what it is recommended for
- label_type (str) – An ENUM of either vector label type or raster label type. Use
one of
LabelType
. - label_properties (dict or None) – 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 (List[LabelClass]) – Optional, but reqiured if ussing categorical data. A list of LabelClasses defining the list of possible class names for each label:properties. (e.g., tree, building, car, hippo)
- label_tasks (str) – 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 (List[LabelOverview]) – Optional list of LabelOverview classes that store counts (for classification-type data) or summary statistics (for continuous numerical/regression data).
- stac_extensions (List[str]) – Optional list of extensions the Item implements.
- href (str or None) – Optional HREF for this item, which be set as the item’s self link’s HREF.
- collection (Collection) – Optional Collection that this item is a part of.
-
id
¶ Provider identifier. Unique within the STAC.
Type: str
-
geometry
¶ Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1 (GeoJSON).
Type: dict
-
bbox
¶ Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array is 2*n where n is the number of dimensions.
Type: List[float]
-
datetime
¶ Datetime associated with this item.
Type: Datetime
-
properties
¶ A dictionary of additional metadata for the item.
Type: dict
-
label_desecription
¶ A description of the label, how it was created, and what it is recommended for
Type: str
-
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.
Type: dict or None
-
label_classes
¶ Optional, but reqiured if ussing categorical data. A list of LabelClasses defining the list of possible class names for each label:properties. (e.g., tree, building, car, hippo)
Type: List[LabelClass]
-
label_tasks
¶ Tasks these labels apply to. Usually a subset of ‘regression’, ‘classification’, ‘detection’, or ‘segmentation’, but may be an arbitrary value.
Type: str
-
label_methods
¶ Methods used for labeling. Usually a subset of ‘automated’ or ‘manual’, but may be an arbitrary value.
-
label_overviews
¶ Optional list of LabelOverview classes that store counts (for classification-type data) or summary statistics (for continuous numerical/regression data).
Type: List[LabelOverview]
-
stac_extensions
¶ Optional list of extensions the Item implements.
Type: List[str] or None
-
collection_id
¶ The Collection ID that this item belongs to, if any.
Type: str or None
-
add_geojson_labels
(href, title=None, properties=None)[source]¶ Adds a GeoJSON label asset to this LabelItem.
Parameters: - href (str) – Link to the asset object. Relative and absolute links are both allowed.
- title (str) – Optional displayed title for clients and users.
- properties (dict) – 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, title=None, media_type=None, properties=None)[source]¶ Adds a label asset to this LabelItem.
Parameters: - href (str) – Link to the asset object. Relative and absolute links are both allowed.
- title (str) – Optional displayed title for clients and users.
- media_type (str) – Optional description of the media type. Registered Media Types
are preferred. See
MediaType
for common media types. - properties (dict) – 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, title=None, assets=None)[source]¶ Adds a link to a source item.
Parameters: - source_item (Item) – Source imagery that the LabelItem applys to.
- title (str) – Optional title for the link.
- assets (List[str]) – Optional list of assets that deterime what assets in the source item this label item data appliees to.
-
clone
()[source]¶ Clones this object.
Cloning an object will make a copy of all properties and links of the object; however, it will not make copies of the targets of links (i.e. it is not a deep copy). To copy a STACObject fully, with all linked elements also copied, use
STACObject.full_copy
.Returns: The clone of this object. Return type: STACObject
-
classmethod
from_dict
(d, href=None, root=None)[source]¶ Parses this STACObject from the passed in dictionary.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The STACObject parsed from this dict.
Return type:
-
classmethod
from_item
(item)[source]¶ Creates a LabelItem from an Item.
Parameters: item (Item) – The Item to create an LabelItem from. Returns: - A new LabelItem from item. If the item
- item is already an LabelItem, simply returns a clone of item.
Return type: LabelItem
-
get_sources
()[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'
.Return type: Generator[Items]
-
to_dict
(include_self_link=True)[source]¶ Generate a dictionary representing the JSON of this serialized object.
Parameters: include_self_link (bool) – If True, the dict will contain a self link to this object. If False, the self link will be omitted. Returns: A serializion of the object that can be written out as JSON. Return type: dict
LabelType¶
LabelClasses¶
-
class
pystac.
LabelClasses
(classes, name=None)[source]¶ - Defines the list of possible class names (e.g.,
- tree, building, car, hippo)
Parameters: - classes (List[str]) – The different possible class values
- name (str) – The property key within the asset’s each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise.
-
classes
¶ The different possible class values
Type: List[str]
-
name
¶ The property key within the asset’s each Feature corresponding to class labels. If labels are raster-formatted, this is None.
Type: str or None
-
static
from_dict
(d)[source]¶ Constructs a LabelClasses from a dict.
Returns: The LabelClasses deserialized from the JSON dict. Return type: LabelClasses
LabelOverview¶
-
class
pystac.
LabelOverview
(property_key, counts=None, statistics=None)[source]¶ Stores counts (for classification-type data) or summary statistics (for continuous numerical/regression data).
Either
counts
orstatistics
, or both, can be placed in an overview; at least one is required.Parameters: - property_key (str) – The property key within the asset corresponding to class labels.
- counts (List[LabelCounts]) – Optional list of LabelCounts.
- statistics (List[Statistics]) – Optional list of Statistics.
- Attributes
- property_key (str): The property key within the asset corresponding to class labels. counts (List[LabelCounts] or None): Optional list of LabelCounts. statistics (List[Statistics] or None): Optional list of Statistics.
-
static
from_dict
(d)[source]¶ Constructs a LabelOverview from a dict.
Returns: The LabelOverview deserialized from the JSON dict. Return type: LabelOverview
-
merge_counts
(other)[source]¶ Merges the counts associated with this overview with another overview.
Parameters: other (LabelOverview) – The other LabelOverview to merge. Returns: A new LabelOverview with the counts merged. This will drop any statistics associated with either of the LabelOverviews. Return type: LabelOverview
LabelCount¶
-
class
pystac.
LabelCount
(name, count)[source]¶ -
static
from_dict
(d)[source]¶ Constructs a LabelCount from a dict.
Returns: The LabelCount deserialized from the JSON dict. Return type: LabelCount
-
static
Single File STAC Extension¶
These classes are representations of the Single File STAC Extension.
SingleFileSTAC¶
-
class
pystac.
SingleFileSTAC
(features=None, collections=None, search=None)[source]¶ Provides a set of Collections and Items as a single file catalog. The single file is a self contained catalog that contains everything that would normally be in a linked set of STAC files.
Parameters: - features (List[Item]) – Optional initial list of items contained by this SingleFileSTAC.
- collections (List[Collection]) – Optional initial list of collections contained by this SingleFileSTAC.
- search (Search) – Optional search information associated with this SingleFileSTAC.
-
collections
¶ Collections contained by this SingleFileSTAC.
Type: List[Collection]
-
search
¶ Optional search information associated with this SingleFileSTAC.
Type: Search
-
links
¶ A list of
Link
objects representing all links associated with this ItemCollection.Type: List[Link]
-
add_collection
(collection)[source]¶ Adds a Collection to this SingleFileSTAC.
Parameters: collection (Collection) – The collection to add.
-
add_collections
(collections)[source]¶ Adds Collections to this SingleFileSTAC.
Parameters: collections (Iterable[Collection]) – The collections to add.
-
static
from_dict
(d)[source]¶ Constructs an SingleFileSTAC from a dict.
Returns: The SingleFileSTAC deserialized from the JSON dict. Return type: SingleFileSTAC
-
static
from_file
(uri)[source]¶ Reads an SingleFileSTAC from a file.
Parameters: href (str) – The HREF to read the item from. Returns: SingleFileSTAC that was read from the given file. Return type: SingleFileSTAC
-
get_collections
()[source]¶ Gets all the collections associated with this SingleFileSTAC.
Returns: The Collections of this SingleFileSTAC Return type: List[Collection]
-
to_dict
(include_self_link=False)[source]¶ Generate a dictionary representing the JSON of this SingleFileSTAC.
Parameters: include_self_link (bool) – If True, writes the ItemCollection’s self link. Defaults to False. Returns: A serializion of the SingleFileSTAC that can be written out as JSON. Return type: dict
Serialization¶
PySTAC includes a pystac.serialization
package for serialization concerns that
are used internally, but may also be useful to external tools.
merge_common_properties¶
-
pystac.serialization.
merge_common_properties
(item_dict, collection_cache=None, json_href=None)[source]¶ Merges Collection properties into an Item.
Parameters: - item_dict (dict) – JSON dict of the Item which properties should be merged into.
- collection_cache (CollectionCache) – 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
indentify_stac_object¶
-
pystac.serialization.
identify_stac_object
(json_dict)[source]¶ Determines the STACJSONDescription of the provided JSON dict.
Parameters: json_dict (dict) – The dict of STAC JSON to identify. Returns: The description of the STAC object serialized in the given dict. Return type: STACJSONDescription Note
Items are expected to have their collection common properties merged into the dict. You can use
merge_common_properties()
to accomplish that. Otherwise, there are cases where the common_extensions returned could be incorrect - e.g. if a collection lists ‘eo’ extension properties but the Item does not contian any properties with the ‘eo:’ prefix.
indentify_stac_object_type¶
-
pystac.serialization.
identify_stac_object_type
(json_dict)[source]¶ Determines the STACObjectType of the provided JSON dict.
Parameters: json_dict (dict) – The dict of STAC JSON to identify. Returns: The object type represented by the JSON. Return type: STACObjectType
STACJSONDescription¶
-
class
pystac.serialization.
STACJSONDescription
(object_type, version_range, common_extensions, custom_extensions)[source]¶ Describes the STAC object information for a STAC object represented in JSON
-
object_type
¶ Describes the STAC object type.
Type: STACObjectType
-
version_range
¶ The STAC version range that describes what has been identified as potential valid versions of the stac object.
Type: STACVersionRange
-
common_extensions
¶ List of common extension IDs implemented by this STAC object.
Type: List[str]
-
custom_extensions
¶ List of custom extensions (URIs to JSON Schemas) used by this STAC Object.
Type: List[str]
-
STACVersionRange¶
PySTAC Internal Classes¶
STACObject¶
-
class
pystac.
STACObject
[source]¶ A STACObject is the base class for any element of STAC that has links e.g. (Catalogs, Collections, or Items). A STACObject has common functionality, can be converted to and from Python
dicts
representing JSON, and can be cloned or copied.-
links
¶ A list of
Link
objects representing all links associated with this STACObject.Type: List[Link]
-
clone
()[source]¶ Clones this object.
Cloning an object will make a copy of all properties and links of the object; however, it will not make copies of the targets of links (i.e. it is not a deep copy). To copy a STACObject fully, with all linked elements also copied, use
STACObject.full_copy
.Returns: The clone of this object. Return type: STACObject
-
classmethod
from_dict
(d, href=None, root=None)[source]¶ Parses this STACObject from the passed in dictionary.
Parameters: - d (dict) – The dict to parse.
- href (str) – Optional href that is the file location of the object being parsed.
- root (Catalog or Collection) – Optional root of the catalog for this object. If provided, the root’s resolved object cache can be used to search for previously resolved instances of the STAC object.
Returns: The STACObject parsed from this dict.
Return type:
-
classmethod
from_file
(href)[source]¶ Reads a STACObject implementation from a file.
Parameters: href (str) – The HREF to read the object from. Returns: The specific STACObject implementation class that is represented by the JSON read from the file located at HREF.
-
full_copy
(root=None, parent=None)[source]¶ Create a full copy of this STAC object and any stac objects linked to by this object.
Parameters: - root (STACObject) – Optional root to set as the root of the copied object, and any other copies that are contained by this object.
- parent (STACObject) – Optional parent to set as the parent of the copy of this object.
Returns: - A full copy of this object, as well as any objects this object
links to.
Return type:
-
fully_resolve
()[source]¶ Ensure all STACObjects linked to by this STACObject are resolved. This is important for operations such as changing HREFs.
This method mutates the entire catalog tree.
-
get_parent
()[source]¶ Get the
Catalog
orCollection
to the parent for this object. The root is represented by aLink
withrel == 'parent'
.Returns: The parent object for this object, or None
if no root link is set.Return type: Catalog, Collection, or None
-
get_root
()[source]¶ Get the
Catalog
orCollection
to the root for this object. The root is represented by aLink
withrel == 'root'
.Returns: The root object for this object, or None
if no root link is set.Return type: Catalog, Collection, or None
-
get_root_link
()[source]¶ Get the
Link
representing the root for this object.Returns: The root link for this object, or None
if no root link is set.Return type: Link
or None
-
get_stac_objects
(rel)[source]¶ Gets the
STACObject
instances that are linked to by links with theirrel
property matching the passed in argument.Parameters: rel (str) – The relation to match each Link
’srel
property against.Returns: A possibly empty generator of STACObjects that are connected to this object through links with the given rel
.Return type: Generator[STACObjects]
-
normalize_hrefs
(root_href)[source]¶ Normalize HREFs will regenerate all link HREFs based on an absolute root_href and the canonical catalog layout as specified in the STAC specification’s best practices.
This method mutates the entire catalog tree.
Parameters: root_href (str) – The absolute HREF that all links will be normalized against. - See:
- STAC best practices document for the canonical layout of a STAC.
-
save_object
(include_self_link=True)[source]¶ Saves this STAC Object to it’s ‘self’ HREF.
Parameters: include_self_link (bool) – If this is true, include the ‘self’ link with this object. Otherwise, leave out the self link. Raises: STACError
– If no self href is set, this error will be raised.Note
When to include a self link is described in the Use of Links section of the STAC best practices document
-
set_parent
(parent, link_type=None)[source]¶ Sets the parent
Catalog
orCollection
for this object.Parameters: - parent (Catalog, Collection or None) – The parent object to set. Passing in None will clear the parent.
- link_type (str) – The link type (see
LinkType
)
-
set_root
(root, link_type=None)[source]¶ Sets the root
Catalog
orCollection
for this object.Parameters: - root (Catalog, Collection or None) – The root object to set. Passing in None will clear the root.
- link_type (str) – The link type (see
LinkType
)
-
to_dict
(include_self_link=True)[source]¶ Generate a dictionary representing the JSON of this serialized object.
Parameters: include_self_link (bool) – If True, the dict will contain a self link to this object. If False, the self link will be omitted. Returns: A serializion of the object that can be written out as JSON. Return type: dict
-