pystac.extensions.raster#

Implements the Raster Extension.

class pystac.extensions.raster.AssetRasterExtension(asset: Asset)[source]#
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.raster.DataType(value)[source]#

An enumeration.

CFLOAT32 = 'cfloat32'#
CFLOAT64 = 'cfloat64'#
CINT16 = 'cint16'#
CINT32 = 'cint32'#
FLOAT16 = 'float16'#
FLOAT32 = 'float32'#
FLOAT64 = 'float64'#
INT16 = 'int16'#
INT32 = 'int32'#
INT64 = 'int64'#
INT8 = 'int8'#
OTHER = 'other'#
UINT16 = 'uint16'#
UINT32 = 'uint32'#
UINT64 = 'uint64'#
UINT8 = 'uint8'#
class pystac.extensions.raster.Histogram(properties: dict[str, Any])[source]#

Represents pixel distribution information attached to a band in the raster extension.

Use Band.create to create a new Band.

apply(count: int, min: float, max: float, buckets: list[int]) None[source]#

Sets the properties for this raster Band.

Parameters:
  • count – number of buckets of the distribution.

  • min – minimum value of the distribution. Also the mean value of the first bucket.

  • max – maximum value of the distribution. Also the mean value of the last bucket.

  • buckets – Array of integer indicating the number of pixels included in the bucket.

property buckets: list[int]#

Get or sets the Array of integer indicating the number of pixels included in the bucket.

Returns:

List[int]

property count: int#

Get or sets the number of buckets of the distribution.

Returns:

int

classmethod create(count: int, min: float, max: float, buckets: list[int]) Histogram[source]#

Creates a new band.

Parameters:
  • count – number of buckets of the distribution.

  • min – minimum value of the distribution. Also the mean value of the first bucket.

  • max – maximum value of the distribution. Also the mean value of the last bucket.

  • buckets – Array of integer indicating the number of pixels included in the bucket.

static from_dict(d: dict[str, Any]) Histogram[source]#

Constructs an Histogram from a dict.

Returns:

The Histogram deserialized from the JSON dict.

Return type:

Histogram

property max: float#

Get or sets the maximum value of the distribution.

Returns:

float

property min: float#

Get or sets the minimum value of the distribution.

Returns:

float

properties: dict[str, Any]#
to_dict() dict[str, Any][source]#

Returns this histogram as a dictionary.

Returns:

The serialization of the Histogram.

Return type:

dict

class pystac.extensions.raster.ItemAssetsRasterExtension(item_asset: AssetDefinition)[source]#
asset_definition: item_assets.AssetDefinition#

A reference to the AssetDefinition being extended.

properties: dict[str, Any]#

The AssetDefinition fields, including extension properties.

class pystac.extensions.raster.NoDataStrings(value)[source]#

An enumeration.

INF = 'inf'#
NAN = 'nan'#
NINF = '-inf'#
class pystac.extensions.raster.RasterBand(properties: dict[str, Any])[source]#

Represents a Raster Band information attached to an Item that implements the raster extension.

Use Band.create to create a new Band.

apply(nodata: float | NoDataStrings | None = None, sampling: Sampling | None = None, data_type: DataType | None = None, bits_per_sample: float | None = None, spatial_resolution: float | None = None, statistics: Statistics | None = None, unit: str | None = None, scale: float | None = None, offset: float | None = None, histogram: Histogram | None = None) None[source]#

Sets the properties for this raster Band.

Parameters:
  • nodata – Pixel values used to identify pixels that are nodata in the assets.

  • sampling – One of area or point. Indicates whether a pixel value should be assumed to represent a sampling over the region of the pixel or a point sample at the center of the pixel.

  • data_type – The data type of the band. One of the data types as described in the Raster Data Types <raster/#data-types> docs extension.

  • bits_per_sample – The actual number of bits used for this band. Normally only present when the number of bits is non-standard for the datatype, such as when a 1 bit TIFF is represented as byte

  • spatial_resolution – Average spatial resolution (in meters) of the pixels in the band.

  • statistics – Statistics of all the pixels in the band

  • unit – unit denomination of the pixel value

  • scale – multiplicator factor of the pixel value to transform into the value (i.e. translate digital number to reflectance).

  • offset – number to be added to the pixel value (after scaling) to transform into the value (i.e. translate digital number to reflectance).

  • histogram – Histogram distribution information of the pixels values in the band

property bits_per_sample: float | None#

Get or sets the actual number of bits used for this band.

Returns:

float

classmethod create(nodata: float | NoDataStrings | None = None, sampling: Sampling | None = None, data_type: DataType | None = None, bits_per_sample: float | None = None, spatial_resolution: float | None = None, statistics: Statistics | None = None, unit: str | None = None, scale: float | None = None, offset: float | None = None, histogram: Histogram | None = None) RasterBand[source]#

Creates a new band.

Parameters:
  • nodata – Pixel values used to identify pixels that are nodata in the assets.

  • sampling – One of area or point. Indicates whether a pixel value should be assumed to represent a sampling over the region of the pixel or a point sample at the center of the pixel.

  • data_type – The data type of the band. One of the data types as described in the Raster Data Types <raster/#data-types> docs extension.

  • bits_per_sample – The actual number of bits used for this band. Normally only present when the number of bits is non-standard for the datatype, such as when a 1 bit TIFF is represented as byte

  • spatial_resolution – Average spatial resolution (in meters) of the pixels in the band.

  • statistics – Statistics of all the pixels in the band

  • unit – unit denomination of the pixel value

  • scale – multiplicator factor of the pixel value to transform into the value (i.e. translate digital number to reflectance).

  • offset – number to be added to the pixel value (after scaling) to transform into the value (i.e. translate digital number to reflectance).

  • histogram – Histogram distribution information of the pixels values in the band

property data_type: DataType | None#

Get or sets the data type of the band.

Returns:

Optional[DataType]

property histogram: Histogram | None#

Get or sets the histogram distribution information of the pixels values in the band.

Returns:

[Histogram]

property nodata: float | NoDataStrings | None#

Get or sets the nodata pixel value

Returns:

Optional[float]

property offset: float | None#

Get or sets the number to be added to the pixel value (after scaling) to transform into the value (i.e. translate digital number to reflectance).

Returns:

[float]

properties: dict[str, Any]#
property sampling: Sampling | None#

Get or sets the property indicating whether a pixel value should be assumed to represent a sampling over the region of the pixel or a point sample at the center of the pixel.

Returns:

Optional[Sampling]

property scale: float | None#

Get or sets the multiplicator factor of the pixel value to transform into the value (i.e. translate digital number to reflectance).

Returns:

[float]

property spatial_resolution: float | None#

Get or sets the average spatial resolution (in meters) of the pixels in the band.

Returns:

[float]

property statistics: Statistics | None#

Get or sets the average spatial resolution (in meters) of the pixels in the band.

Returns:

[Statistics]

to_dict() dict[str, Any][source]#

Returns this band as a dictionary.

Returns:

The serialization of the Band.

Return type:

dict

property unit: str | None#

Get or sets the unit denomination of the pixel value

Returns:

[str]

class pystac.extensions.raster.RasterExtension[source]#

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

This class will generally not be used directly. Instead, use the concrete implementation associated with the STAC Object you want to extend (e.g. ItemRasterExtension to extend an Item). You may prefer to use the ext class method of this class to construct the correct instance type for you.

apply(bands: list[pystac.extensions.raster.RasterBand]) None[source]#

Applies raster extension properties to the extended pystac.Item or pystac.Asset.

Parameters:

bands – a list of RasterBand objects that represent the available raster bands.

property bands: list[RasterBand] | None#

Gets or sets a list of available bands where each item is a RasterBand object (or None if no bands have been set). If not available the field should not be provided.

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

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

This extension can be applied to instances of Asset.

Raises:

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

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['raster'] = 'raster'#
properties: dict[str, Any]#

The Asset fields, including extension properties.

classmethod summaries(obj: Collection, add_if_missing: bool = False) SummariesRasterExtension[source]#
class pystac.extensions.raster.RasterExtensionHooks[source]#
prev_extension_ids: set[str] = {'https://stac-extensions.github.io/raster/v1.0.0/schema.json'}#
schema_uri: str = 'https://stac-extensions.github.io/raster/v1.1.0/schema.json'#
stac_object_types = {STACObjectType.COLLECTION, STACObjectType.ITEM}#
class pystac.extensions.raster.Sampling(value)[source]#

An enumeration.

AREA = 'area'#
POINT = 'point'#
class pystac.extensions.raster.Statistics(properties: dict[str, float | None])[source]#

Represents statistics information attached to a band in the raster extension.

Use Statistics.create to create a new Statistics instance.

apply(minimum: float | None = None, maximum: float | None = None, mean: float | None = None, stddev: float | None = None, valid_percent: float | None = None) None[source]#

Sets the properties for this raster Band.

Parameters:
  • minimum – Minimum value of all the pixels in the band.

  • maximum – Maximum value of all the pixels in the band.

  • mean – Mean value of all the pixels in the band.

  • stddev – Standard Deviation value of all the pixels in the band.

  • valid_percent – Percentage of valid (not nodata) pixel.

classmethod create(minimum: float | None = None, maximum: float | None = None, mean: float | None = None, stddev: float | None = None, valid_percent: float | None = None) Statistics[source]#

Creates a new band.

Parameters:
  • minimum – Minimum value of all the pixels in the band.

  • maximum – Maximum value of all the pixels in the band.

  • mean – Mean value of all the pixels in the band.

  • stddev – Standard Deviation value of all the pixels in the band.

  • valid_percent – Percentage of valid (not nodata) pixel.

static from_dict(d: dict[str, Any]) Statistics[source]#

Constructs an Statistics from a dict.

Returns:

The Statistics deserialized from the JSON dict.

Return type:

Statistics

property maximum: float | None#

Get or sets the maximum pixel value

Returns:

Optional[float]

property mean: float | None#

Get or sets the mean pixel value

Returns:

Optional[float]

property minimum: float | None#

Get or sets the minimum pixel value

Returns:

Optional[float]

properties: dict[str, Any]#
property stddev: float | None#

Get or sets the standard deviation pixel value

Returns:

Optional[float]

to_dict() dict[str, Any][source]#

Returns these statistics as a dictionary.

Returns:

The serialization of the Statistics.

Return type:

dict

property valid_percent: float | None#

Get or sets the Percentage of valid (not nodata) pixel

Returns:

Optional[float]

class pystac.extensions.raster.SummariesRasterExtension(collection: Collection)[source]#

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

property bands: list[RasterBand] | None#

Get or sets a list of Band objects that represent the available bands.

summaries: Summaries#

The summaries for the Collection being extended.