Skip to content

Landsat Collection 2

Readers

class

rio_tiler_pds.landsat.aws.landsat_collection2.LandsatC2Reader(input, tms=<TileMatrixSet title='Google Maps Compatible for the World' id='WebMercatorQuad' crs='http://www.opengis.net/def/crs/EPSG/0/3857>, minzoom=5, maxzoom=12, reader=<class 'rio_tiler.io.rasterio.Reader'>, reader_options=NOTHING, bucket='usgs-landsat', prefix_pattern='collection02/level-{_processingLevelNum}/{category}/{_sensor_s3_prefix}/{acquisitionYear}/{path}/{row}/{scene}/{scene}')

Bases
rio_tiler.io.base.MultiBandReader rio_tiler.io.base.SpatialMixin

AWS Public Dataset Landsat Collection 2 COG Reader.

Parameters
  • tms (TileMatrixSet, optional)
  • input (str) Landsat 8 sceneid.
  • minzoom (int, optional)
  • maxzoom (int, optional)
  • reader_options (dict, optional)
  • reader (type of Reader, optional)
  • bucket (str, optional)
  • prefix_pattern (str, optional)
Attributes
  • bands (tuple) list of available bands.
  • bounds
  • crs
  • geographic_bounds (float, float, float, float) Return dataset bounds in geographic_crs.
  • input (any) input data.
  • maxzoom (int) Dataset's Max Zoom level (default is 12).
  • minzoom (int) Dataset's Min Zoom level (default is 5).
  • reader_options (dict, option) options to forward to the reader. Defaults to {}.
  • scene_params (dict) scene id parameters.
  • stac_item
  • tms (morecantile.TileMatrixSet, optional) TileMatrixSet grid definition. Defaults to WebMercatorQuad.
Examples
>>> with LandsatC2Reader('LC08_L2SR_093106_20200207_20201016_02_T2') as scene:
        print(scene.bounds)
>>> with LandsatC2Reader('LC08_L1TP_116043_20201122_20201122_02_RT') as scene:
        print(scene.bounds)
Methods
  • __attrs_post_init__() Fetch productInfo and get bounds.
  • __enter__() Support using with Context Managers.
  • __exit__(exc_type, exc_value, traceback) Support using with Context Managers.
  • feature(shape, bands, expression, **kwargs) (rio_tiler.models.ImageData) Read and merge parts defined by geojson feature from multiple bands.
  • get_geometry() Fetch geometry info for the scene.
  • info(bands, *args, **kwargs) (dict) Return metadata from multiple bands.
  • parse_expression(expression) (tuple) Parse rio-tiler band math expression.
  • part(bbox, bands, expression, **kwargs) (rio_tiler.models.ImageData) Read and merge parts from multiple bands.
  • point(lon, lat, bands, expression, **kwargs) (PointData) Read a pixel values from multiple bands.
  • preview(bands, expression, **kwargs) (rio_tiler.models.ImageData) Read and merge previews from multiple bands.
  • statistics(bands, expression, categorical, categories, percentiles, hist_options, max_size, **kwargs) (dict) Return array statistics for multiple assets.
  • tile(tile_x, tile_y, tile_z, bands, expression, **kwargs) (rio_tiler.models.ImageData) Read and merge Web Map tiles multiple bands.
  • tile_exists(tile_x, tile_y, tile_z) (bool) Check if a tile intersects the dataset bounds.
method

tile_exists(tile_x, tile_y, tile_z)

Check if a tile intersects the dataset bounds.

Parameters
  • tile_x (int) Tile's horizontal index.
  • tile_y (int) Tile's vertical index.
  • tile_z (int) Tile's zoom level index.
Returns (bool)

True if the tile intersects the dataset bounds.

method

__enter__()

Support using with Context Managers.

method

__exit__(exc_type, exc_value, traceback)

Support using with Context Managers.

Parameters
  • exc_type
  • exc_value
  • traceback
method

parse_expression(expression) → tuple

Parse rio-tiler band math expression.

Parameters
  • expression (str)
method

info(bands=None, *args, **kwargs)

Return metadata from multiple bands.

Parameters
  • bands (sequence of str or str, optional) band names to fetch info from. Required keyword argument.
  • *args
  • **kwargs (any)
Returns (dict)

Multiple bands info in form of {"band1": rio_tile.models.Info}.

method

statistics(bands=None, expression=None, categorical=False, categories=None, percentiles=None, hist_options=None, max_size=1024, **kwargs)

Return array statistics for multiple assets.

Parameters
  • bands (sequence of str or str) bands to fetch info from. Required keyword argument.
  • expression (str, optional) rio-tiler expression for the band list (e.g. b1/b2+b3).
  • categorical (bool) treat input data as categorical data. Defaults to False.
  • categories (list of numbers, optional) list of categories to return value for.
  • percentiles (list of numbers, optional) list of percentile values to calculate. Defaults to [2, 98].
  • hist_options (dict, optional) Options to forward to numpy.histogram function.
  • max_size (int, optional) Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024.
  • **kwargs (any)
Returns (dict)

Multiple assets statistics in form of {"{band}/{expression}": rio_tiler.models.BandStatistics, ...}.

method

tile(tile_x, tile_y, tile_z, bands=None, expression=None, **kwargs)

Read and merge Web Map tiles multiple bands.

Parameters
  • tile_x (int) Tile's horizontal index.
  • tile_y (int) Tile's vertical index.
  • tile_z (int) Tile's zoom level index.
  • bands (sequence of str or str, optional) bands to fetch info from.
  • expression (str, optional) rio-tiler expression for the band list (e.g. b1/b2+b3).
  • **kwargs (any)
Returns (rio_tiler.models.ImageData)

ImageData instance with data, mask and tile spatial info.

method

part(bbox, bands=None, expression=None, **kwargs)

Read and merge parts from multiple bands.

Parameters
  • bbox (tuple) Output bounds (left, bottom, right, top) in target crs.
  • bands (sequence of str or str, optional) bands to fetch info from.
  • expression (str, optional) rio-tiler expression for the band list (e.g. b1/b2+b3).
  • **kwargs (any)
Returns (rio_tiler.models.ImageData)

ImageData instance with data, mask and tile spatial info.

method

preview(bands=None, expression=None, **kwargs)

Read and merge previews from multiple bands.

Parameters
  • bands (sequence of str or str, optional) bands to fetch info from.
  • expression (str, optional) rio-tiler expression for the band list (e.g. b1/b2+b3).
  • **kwargs (any)
Returns (rio_tiler.models.ImageData)

ImageData instance with data, mask and tile spatial info.

method

point(lon, lat, bands=None, expression=None, **kwargs)

Read a pixel values from multiple bands.

Parameters
  • lon (float) Longitude.
  • lat (float) Latitude.
  • bands (sequence of str or str, optional) bands to fetch info from.
  • expression (str, optional) rio-tiler expression for the band list (e.g. b1/b2+b3).
  • **kwargs (any)
Returns (PointData)

PointData

method

feature(shape, bands=None, expression=None, **kwargs)

Read and merge parts defined by geojson feature from multiple bands.

Parameters
  • shape (dict) Valid GeoJSON feature.
  • bands (sequence of str or str, optional) bands to fetch info from.
  • expression (str, optional) rio-tiler expression for the band list (e.g. b1/b2+b3).
  • **kwargs (any)
Returns (rio_tiler.models.ImageData)

ImageData instance with data, mask and tile spatial info.

Fetch productInfo and get bounds.

method

get_geometry()

Fetch geometry info for the scene.

Utils

function

rio_tiler_pds.landsat.utils.sceneid_parser(sceneid)

Parse Landsat id.

Author @perrygeo - www.perrygeo.com

Parameters
  • sceneid (str) Landsat sceneid.
Returns (dict)

dictionary with metadata constructed from the sceneid.

Raises
  • InvalidLandsatSceneId If sceneid doesn't match the regex schema.
Examples
>>> sceneid_parser('LC08_L1TP_016037_20170813_20170814_01_RT')