How to use the pystac.item.Item function in pystac

To help you get started, we’ve selected a few pystac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github azavea / pystac / pystac / extensions / projection.py View on Github external
if asset is None:
            self.item.properties['proj:transform'] = transform
        else:
            asset.properties['proj:transform'] = transform

    @classmethod
    def _object_links(cls):
        return []

    @classmethod
    def from_item(cls, item):
        return cls(item)


PROJECTION_EXTENSION_DEFINITION = ExtensionDefinition(Extensions.PROJECTION,
                                                      [ExtendedObject(Item, ProjectionItemExt)])
github azavea / pystac / pystac / extensions / label.py View on Github external
    @value.setter
    def value(self, v):
        self.properties['value'] = v

    def to_dict(self):
        """Returns the dictionary representing the JSON of this LabelStatistics.

        Returns:
            dict: The wrapped dict of the LabelStatistics that can be written out as JSON.
        """
        return {'name': self.name, 'value': self.value}


LABEL_EXTENSION_DEFINITION = ExtensionDefinition(Extensions.LABEL,
                                                 [ExtendedObject(Item, LabelItemExt)])
github azavea / pystac / pystac / extensions / view.py View on Github external
    @sun_elevation.setter
    def sun_elevation(self, v):
        self.item.properties['view:sun_elevation'] = v

    @classmethod
    def _object_links(cls):
        return []

    @classmethod
    def from_item(cls, item):
        return cls(item)


VIEW_EXTENSION_DEFINITION = ExtensionDefinition(Extensions.VIEW,
                                                [ExtendedObject(Item, ViewItemExt)])
github azavea / pystac / pystac / item.py View on Github external
def clone(self):
        clone = Item(id=self.id,
                     geometry=deepcopy(self.geometry),
                     bbox=copy(self.bbox),
                     datetime=copy(self.datetime),
                     properties=deepcopy(self.properties),
                     stac_extensions=deepcopy(self.stac_extensions))
        for link in self.links:
            clone.add_link(link.clone())

        clone.assets = dict([(k, a.clone()) for (k, a) in self.assets.items()])

        return clone
github azavea / pystac / pystac / item.py View on Github external
def from_dict(cls, d, href=None, root=None):
        id = d['id']
        geometry = d['geometry']
        bbox = d['bbox']
        properties = d['properties']
        stac_extensions = d.get('stac_extensions')
        collection_id = None
        if 'collection' in d.keys():
            collection_id = d['collection']

        datetime = properties.get('datetime')
        if datetime is None:
            raise STACError('Item dict is missing a "datetime" property in the "properties" field')
        datetime = dateutil.parser.parse(datetime)

        item = Item(id=id,
                    geometry=geometry,
                    bbox=bbox,
                    datetime=datetime,
                    properties=properties,
                    stac_extensions=stac_extensions,
                    collection=collection_id)

        has_self_link = False
        for l in d['links']:
            has_self_link |= l['rel'] == 'self'
            item.add_link(Link.from_dict(l))

        if not has_self_link and href is not None:
            item.add_link(Link.self_href(href))

        for k, v in d['assets'].items():
github azavea / pystac / pystac / eo.py View on Github external
from copy import deepcopy

from pystac.item import (Item, Asset)
from pystac import STACError


class EOItem(Item):
    """EOItem represents a snapshot of the earth for a single date and time.

    Args:
        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 :class:`~pystac.Band` objects that represent
github azavea / pystac / pystac / extensions / base.py View on Github external
def __init__(self, stac_object_class, extension_class):
        if stac_object_class is Catalog:
            if not issubclass(extension_class, CatalogExtension):
                raise ExtensionError(
                    "Classes extending catalogs must inheret from CatalogExtension")
        if stac_object_class is Collection:
            if not issubclass(extension_class, CollectionExtension):
                raise ExtensionError(
                    "Classes extending collections must inheret from CollectionExtension")
        if stac_object_class is Item:
            if not issubclass(extension_class, ItemExtension):
                raise ExtensionError("Classes extending item must inheret from ItemExtension")

        self.stac_object_class = stac_object_class
        self.extension_class = extension_class