pystac.extensions.projection#

Implements the Projection Extension.

class pystac.extensions.projection.AssetProjectionExtension(asset: Asset)[source]#

A concrete implementation of ProjectionExtension on an Asset that extends the Asset fields to include properties defined in the Projection Extension.

This class should generally not be instantiated directly. Instead, call ProjectionExtension.ext() on an Asset to extend it.

additional_read_properties: Iterable[dict[str, Any]] | None = None#

If present, this will be a list containing 1 dictionary representing the properties of the owning Item.

asset_href: str#

The href value of the Asset being extended.

properties: dict[str, Any]#

The Asset fields, including extension properties.

class pystac.extensions.projection.ItemAssetsProjectionExtension(item_asset: AssetDefinition)[source]#
asset_defn: item_assets.AssetDefinition#
properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

class pystac.extensions.projection.ItemProjectionExtension(item: Item)[source]#

A concrete implementation of ProjectionExtension on an Item that extends the properties of the Item to include properties defined in the Projection Extension.

This class should generally not be instantiated directly. Instead, call ProjectionExtension.ext() on an Item to extend it.

item: pystac.Item#

The Item being extended.

properties: dict[str, Any]#

The Item properties, including extension properties.

class pystac.extensions.projection.ProjectionExtension[source]#

An abstract class that can be used to extend the properties of an Item with properties from the Projection Extension. This class is generic over the type of STAC Object to be extended (e.g. Item, Collection).

To create a concrete instance of ProjectionExtension, use the ProjectionExtension.ext() method. For example:

>>> item: pystac.Item = ...
>>> proj_ext = ProjectionExtension.ext(item)
apply(epsg: int | None, wkt2: str | None = None, projjson: dict[str, Any] | None = None, geometry: dict[str, Any] | None = None, bbox: list[float] | None = None, centroid: dict[str, float] | None = None, shape: list[int] | None = None, transform: list[float] | None = None) None[source]#

Applies Projection extension properties to the extended Item.

Parameters:
  • epsg – REQUIRED. EPSG code of the datasource.

  • wkt2 – WKT2 string representing the Coordinate Reference System (CRS) that the geometry and bbox fields represent

  • projjson – PROJJSON dict representing the Coordinate Reference System (CRS) that the geometry and bbox fields represent

  • geometry – GeoJSON Polygon dict that defines the footprint of this Item.

  • bbox – Bounding box of the Item in the asset CRS in 2 or 3 dimensions.

  • centroid – A dict with members ‘lat’ and ‘lon’ that defines coordinates representing the centroid of the item in the asset data CRS. Coordinates are defined in latitude and longitude, even if the data coordinate system may not use lat/long.

  • shape – Number of pixels in Y and X directions for the default grid.

  • transform – The affine transformation coefficients for the default grid

property bbox: list[float] | None#

Get or sets the bounding box of the assets represented by this item in the asset data CRS.

Specified as 4 or 6 coordinates based on the CRS defined in the epsg, projjson or wkt2 properties. First two numbers are coordinates of the lower left corner, followed by coordinates of upper right corner, e.g., [west, south, east, north], [xmin, ymin, xmax, ymax], [left, down, right, up], or [west, south, lowest, east, north, highest]. The length of the array must be 2*n where n is the number of dimensions.

property centroid: dict[str, float] | None#

Get or sets coordinates representing the centroid of the item in the asset data CRS.

Coordinates are defined in latitude and longitude, even if the data coordinate system does not use lat/long.

Example:

item.ext.proj.centroid = { 'lat': 0.0, 'lon': 0.0 }
property crs_string: str | None#

Returns the coordinate reference system (CRS) string for the extension.

This string can be used to feed, e.g., rasterio.crs.CRS.from_string. The string is determined by the following heuristic:

  1. If an EPSG code is set, return “EPSG:{code}”, else

  2. If wkt2 is set, return the WKT string, else,

  3. If projjson is set, return the projjson as a string, else,

  4. Return None

property epsg: int | None#

Get or sets the EPSG code of the datasource.

A Coordinate Reference System (CRS) is the data reference system (sometimes called a ‘projection’) used by the asset data, and can usually be referenced using an EPSG code. If the asset data does not have a CRS, such as in the case of non-rectified imagery with Ground Control Points, epsg should be set to None. It should also be set to None if a CRS exists, but for which there is no valid EPSG code.

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

Extends the given STAC Object with properties from the Projection Extension.

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

Raises:

pystac.ExtensionTypeError – If an invalid object type is passed.

property geometry: dict[str, Any] | None#

Get or sets a Polygon GeoJSON dict representing the footprint of this item.

This dict should be formatted according the Polygon object format specified in RFC 7946, sections 3.1.6, except not necessarily in EPSG:4326 as required by RFC7946. Specified based on the epsg, projjson or wkt2 fields (not necessarily EPSG:4326). Ideally, this will be represented by a Polygon with five coordinates, as the item in the asset data CRS should be a square aligned to the original CRS grid.

classmethod get_schema_uri() str[source]#

Gets the schema URI associated with this extension.

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

Gets a list of schema URIs associated with this extension.

name: Literal['proj'] = 'proj'#
property projjson: dict[str, Any] | None#

Get or sets the PROJJSON string representing the Coordinate Reference System (CRS) that the proj:geometry and proj:bbox fields represent

This value is a PROJJSON object. If the data does not have a CRS, such as in the case of non-rectified imagery with Ground Control Points, projjson should be set to None. It should also be set to None if a CRS exists, but for which a PROJJSON string does not exist.

The schema for this object can be found here.

property shape: list[int] | None#

Get or sets the number of pixels in Y and X directions for the default grid.

The shape is an array of integers that represents the number of pixels in the most common pixel grid used by the item’s assets. The number of pixels should be specified in Y, X order. If the shape is defined in an item’s properties it is used as the default shape for all assets that don’t have an overriding shape.

classmethod summaries(obj: Collection, add_if_missing: bool = False) SummariesProjectionExtension[source]#

Returns the extended summaries object for the given collection.

property transform: list[float] | None#

Get or sets the the affine transformation coefficients for the default grid.

The transform is a linear mapping from pixel coordinate space (Pixel, Line) to projection coordinate space (Xp, Yp). It is a 3x3 matrix stored as a flat array of 9 elements in row major order. Since the last row is always 0,0,1 it can be omitted, in which case only 6 elements are recorded. This mapping can be obtained from GDAL GetGeoTransform or the Rasterio Transform.

property wkt2: str | None#

Get or sets the WKT2 string representing the Coordinate Reference System (CRS) that the proj:geometry and proj:bbox fields represent

This value is a WKT2 string. If the data does not have a CRS, such as in the case of non-rectified imagery with Ground Control Points, wkt2 should be set to None. It should also be set to None if a CRS exists, but for which a WKT2 string does not exist.

class pystac.extensions.projection.ProjectionExtensionHooks[source]#
prev_extension_ids = {'https://stac-extensions.github.io/projection/v1.0.0/schema.json', 'proj', 'projection'}#
schema_uri: str = 'https://stac-extensions.github.io/projection/v1.1.0/schema.json'#
stac_object_types = {STACObjectType.ITEM}#
class pystac.extensions.projection.SummariesProjectionExtension(collection: Collection)[source]#

A concrete implementation of SummariesExtension that extends the summaries field of a Collection to include properties defined in the Projection Extension.

property epsg: list[int] | None#

Get or sets the summary of ProjectionExtension.epsg values for this Collection.

summaries: Summaries#

The summaries for the Collection being extended.