pystac.extensions.projection#
Implements the Projection Extension.
- class pystac.extensions.projection.AssetProjectionExtension(asset: Asset)[source]#
A concrete implementation of
ProjectionExtension
on anAsset
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 anAsset
to extend it.
- class pystac.extensions.projection.ItemProjectionExtension(item: Item)[source]#
A concrete implementation of
ProjectionExtension
on anItem
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 anItem
to extend it.
- class pystac.extensions.projection.ProjectionExtension(*args, **kwds)[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 theProjectionExtension.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
andbbox
fields representprojjson – PROJJSON dict representing the Coordinate Reference System (CRS) that the
geometry
andbbox
fields representgeometry – 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
orwkt2
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:If an EPSG code is set, return “EPSG:{code}”, else
If wkt2 is set, return the WKT string, else,
If projjson is set, return the projjson as a string, else,
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 toNone
. It should also be set toNone
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
orAsset
.- 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
orwkt2
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_uris() List[str] [source]#
Gets a list of schema URIs associated with this extension.
- property projjson: Dict[str, Any] | None#
Get or sets the PROJJSON string representing the Coordinate Reference System (CRS) that the
proj:geometry
andproj:bbox
fields representThis 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 toNone
. It should also be set toNone
if a CRS exists, but for which a PROJJSON string does not exist.The schema for this object can be found here.
- 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.
- 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
andproj:bbox
fields representThis 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 toNone
. It should also be set toNone
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'}#
- stac_object_types = {STACObjectType.ITEM}#
- class pystac.extensions.projection.SummariesProjectionExtension(collection: Collection)[source]#
A concrete implementation of
SummariesExtension
that extends thesummaries
field of aCollection
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.