rio_tiler.io.base
rio_tiler.io.base ¶
rio_tiler.io.base: ABC class for rio-tiler readers.
BaseReader ¶
Bases: SpatialMixin
Rio-tiler.io BaseReader.
Attributes:
-
input
(any
) –Reader's input.
-
tms
(TileMatrixSet
) –TileMatrixSet grid definition. Defaults to
WebMercatorQuad
.
feature
abstractmethod
¶
point
abstractmethod
¶
preview
abstractmethod
¶
preview() -> ImageData
Read a preview of a Dataset.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
statistics
abstractmethod
¶
statistics() -> Dict[str, BandStatistics]
Return bands statistics from a dataset.
Returns:
-
Dict[str, BandStatistics]
–Dict[str, rio_tiler.models.BandStatistics]: bands statistics.
tile
abstractmethod
¶
MultiBandReader ¶
Bases: SpatialMixin
Multi Band Reader.
This Abstract Base Class Reader is suited for dataset that stores spectral bands as separate files (e.g. Sentinel 2).
Attributes:
-
input
(any
) –input data.
-
tms
(TileMatrixSet
) –TileMatrixSet grid definition. Defaults to
WebMercatorQuad
. -
minzoom
(int
) –Set dataset's minzoom.
-
maxzoom
(int
) –Set dataset's maxzoom.
-
reader_options
((dict, option)
) –options to forward to the reader. Defaults to
{}
.
_get_band_url
abstractmethod
¶
Validate band name and construct url.
feature ¶
feature(shape: Dict, bands: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, **kwargs: Any) -> ImageData
Read and merge parts defined by geojson feature from multiple bands.
Parameters:
-
shape
(dict
) –Valid GeoJSON feature.
-
bands
(sequence of str or str
, default:None
) –bands to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the band list (e.g. b1/b2+b3).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.feature
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
info ¶
Return metadata from multiple bands.
Parameters:
-
bands
(sequence of str or str
, default:None
) –band names to fetch info from. Required keyword argument.
Returns:
-
dict
(Info
) –Multiple bands info in form of {"band1": rio_tile.models.Info}.
part ¶
part(bbox: BBox, bands: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, **kwargs: Any) -> ImageData
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
, default:None
) –bands to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the band list (e.g. b1/b2+b3).
-
kwargs
(optional
, default:{}
) –Options to forward to the 'self.reader.part' method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
point ¶
point(lon: float, lat: float, bands: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, **kwargs: Any) -> PointData
Read a pixel values from multiple bands.
Parameters:
-
lon
(float
) –Longitude.
-
lat
(float
) –Latitude.
-
bands
(sequence of str or str
, default:None
) –bands to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the band list (e.g. b1/b2+b3).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.point
method.
Returns:
-
PointData
–PointData
preview ¶
preview(bands: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, **kwargs: Any) -> ImageData
Read and merge previews from multiple bands.
Parameters:
-
bands
(sequence of str or str
, default:None
) –bands to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the band list (e.g. b1/b2+b3).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.preview
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
statistics ¶
statistics(bands: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, categorical: bool = False, categories: Optional[List[float]] = None, percentiles: Optional[List[int]] = None, hist_options: Optional[Dict] = None, max_size: int = 1024, **kwargs: Any) -> Dict[str, BandStatistics]
Return array statistics for multiple assets.
Parameters:
-
bands
(sequence of str or str
, default:None
) –bands to fetch info from. Required keyword argument.
-
expression
(str
, default:None
) –rio-tiler expression for the band list (e.g. b1/b2+b3).
-
categorical
(bool
, default:False
) –treat input data as categorical data. Defaults to False.
-
categories
(list of numbers
, default:None
) –list of categories to return value for.
-
percentiles
(list of numbers
, default:None
) –list of percentile values to calculate. Defaults to
[2, 98]
. -
hist_options
(dict
, default:None
) –Options to forward to numpy.histogram function.
-
max_size
(int
, default:1024
) –Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024.
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.preview
method.
Returns:
-
dict
(Dict[str, BandStatistics]
) –Multiple assets statistics in form of {"{band}/{expression}": rio_tiler.models.BandStatistics, ...}.
tile ¶
tile(tile_x: int, tile_y: int, tile_z: int, bands: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, **kwargs: Any) -> ImageData
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
, default:None
) –bands to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the band list (e.g. b1/b2+b3).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.tile
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
MultiBaseReader ¶
Bases: SpatialMixin
MultiBaseReader Reader.
This Abstract Base Class Reader is suited for dataset that are composed of multiple assets (e.g. STAC).
Attributes:
-
input
(any
) –input data.
-
tms
(TileMatrixSet
) –TileMatrixSet grid definition. Defaults to
WebMercatorQuad
. -
minzoom
(int
) –Set dataset's minzoom.
-
maxzoom
(int
) –Set dataset's maxzoom.
-
reader_options
((dict, option)
) –options to forward to the reader. Defaults to
{}
.
_get_asset_info
abstractmethod
¶
_get_asset_info(asset: str) -> AssetInfo
Validate asset name and construct url.
_get_reader ¶
_get_reader(asset_info: AssetInfo) -> Tuple[Type[BaseReader], Dict]
Get Asset Reader and options.
_update_statistics ¶
_update_statistics(img: ImageData, indexes: Optional[Indexes] = None, statistics: Optional[Sequence[Tuple[float, float]]] = None)
Update ImageData Statistics from AssetInfo.
feature ¶
feature(shape: Dict, assets: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, asset_as_band: bool = False, **kwargs: Any) -> ImageData
Read and merge parts defined by geojson feature from multiple assets.
Parameters:
-
shape
(dict
) –Valid GeoJSON feature.
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.feature
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
info ¶
merged_statistics ¶
merged_statistics(assets: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, categorical: bool = False, categories: Optional[List[float]] = None, percentiles: Optional[List[int]] = None, hist_options: Optional[Dict] = None, max_size: int = 1024, **kwargs: Any) -> Dict[str, BandStatistics]
Return array statistics for multiple assets.
Parameters:
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
categorical
(bool
, default:False
) –treat input data as categorical data. Defaults to False.
-
categories
(list of numbers
, default:None
) –list of categories to return value for.
-
percentiles
(list of numbers
, default:None
) –list of percentile values to calculate. Defaults to
[2, 98]
. -
hist_options
(dict
, default:None
) –Options to forward to numpy.histogram function.
-
max_size
(int
, default:1024
) –Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024.
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.preview
method.
Returns:
-
Dict[str, BandStatistics]
–Dict[str, rio_tiler.models.BandStatistics]: bands statistics.
parse_expression ¶
Parse rio-tiler band math expression.
part ¶
part(bbox: BBox, assets: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, asset_as_band: bool = False, **kwargs: Any) -> ImageData
Read and merge parts from multiple assets.
Parameters:
-
bbox
(tuple
) –Output bounds (left, bottom, right, top) in target crs.
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.part
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
point ¶
point(lon: float, lat: float, assets: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, asset_as_band: bool = False, **kwargs: Any) -> PointData
Read pixel value from multiple assets.
Parameters:
-
lon
(float
) –Longitude.
-
lat
(float
) –Latitude.
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.point
method.
Returns:
-
PointData
–PointData
preview ¶
preview(assets: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, asset_as_band: bool = False, **kwargs: Any) -> ImageData
Read and merge previews from multiple assets.
Parameters:
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.preview
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
statistics ¶
statistics(assets: Optional[Union[Sequence[str], str]] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, asset_expression: Optional[Dict[str, str]] = None, **kwargs: Any) -> Dict[str, Dict[str, BandStatistics]]
Return array statistics for multiple assets.
Parameters:
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
asset_expression
(dict
, default:None
) –rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.statistics
method.
Returns:
-
dict
(Dict[str, Dict[str, BandStatistics]]
) –Multiple assets statistics in form of {"asset1": {"1": rio_tiler.models.BandStatistics, ...}}.
tile ¶
tile(tile_x: int, tile_y: int, tile_z: int, assets: Optional[Union[Sequence[str], str]] = None, expression: Optional[str] = None, asset_indexes: Optional[Dict[str, Indexes]] = None, asset_as_band: bool = False, **kwargs: Any) -> ImageData
Read and merge Wep Map tiles from multiple assets.
Parameters:
-
tile_x
(int
) –Tile's horizontal index.
-
tile_y
(int
) –Tile's vertical index.
-
tile_z
(int
) –Tile's zoom level index.
-
assets
(sequence of str or str
, default:None
) –assets to fetch info from.
-
expression
(str
, default:None
) –rio-tiler expression for the asset list (e.g. asset1/asset2+asset3).
-
asset_indexes
(dict
, default:None
) –Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}).
-
kwargs
(optional
, default:{}
) –Options to forward to the
self.reader.tile
method.
Returns:
-
ImageData
–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
SpatialMixin ¶
Spatial Info Mixin.
Attributes:
-
tms
(TileMatrixSet
) –TileMatrixSet grid definition. Defaults to
WebMercatorQuad
.