rio_tiler.io.xarray
rio_tiler.io.xarray ¶
rio_tiler.io.xarray: Xarray Reader.
XarrayReader ¶
Bases: BaseReader
Xarray Reader.
Attributes:
-
dataset(DataArray) –Xarray DataArray dataset.
-
tms(TileMatrixSet) –TileMatrixSet grid definition. Defaults to
WebMercatorQuad.
Examples:
>>> ds = xarray.open_dataset(
"https://pangeo.blob.core.windows.net/pangeo-public/daymet-rio-tiler/na-wgs84.zarr",
engine="zarr",
decode_coords="all",
consolidated=True,
)
da = ds["tmax"]
with XarrayReader(da) as dst:
img = dst.tile(...)
band_descriptions
property
¶
Return list of band descriptions in DataArray.
Bands are all dimensions not defined as spatial dims by rioxarray.
_sel_indexes ¶
Select band indexes in DataArray.
feature ¶
feature(shape: Dict, dst_crs: CRS | None = None, shape_crs: CRS = WGS84_CRS, reproject_method: WarpResampling = 'nearest', auto_expand: bool = True, nodata: NoData | None = None, indexes: Indexes | None = None, max_size: int | None = None, height: int | None = None, width: int | None = None, resampling_method: RIOResampling = 'nearest', out_dtype: str | dtype | None = None, **kwargs: Any) -> ImageData
Read part of a dataset defined by a geojson feature.
Parameters:
-
shape(dict) –Valid GeoJSON feature.
-
dst_crs(CRS, default:None) –Overwrite target coordinate reference system.
-
shape_crs(CRS, default:WGS84_CRS) –Input geojson coordinate reference system. Defaults to
epsg:4326. -
reproject_method(WarpResampling, default:'nearest') –WarpKernel resampling algorithm. Defaults to
nearest. -
auto_expand(boolean, default:True) –When True, rioxarray's clip_box will expand clip search if only 1D raster found with clip. When False, will throw
OneDimensionalRastererror if only 1 x or y data point is found. Defaults to True. -
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
-
max_size(int, default:None) –Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio.
-
height(int, default:None) –Output height of the array.
-
width(int, default:None) –Output width of the array.
-
resampling_method(RIOResampling, default:'nearest') –RasterIO resampling algorithm. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
part ¶
part(bbox: BBox, dst_crs: CRS | None = None, bounds_crs: CRS = WGS84_CRS, reproject_method: WarpResampling = 'nearest', auto_expand: bool = True, nodata: NoData | None = None, indexes: Indexes | None = None, max_size: int | None = None, height: int | None = None, width: int | None = None, resampling_method: RIOResampling = 'nearest', out_dtype: str | dtype | None = None, **kwargs: Any) -> ImageData
Read part of a dataset.
Parameters:
-
bbox(tuple) –Output bounds (left, bottom, right, top) in target crs ("dst_crs").
-
dst_crs(CRS, default:None) –Overwrite target coordinate reference system.
-
bounds_crs(CRS, default:WGS84_CRS) –Bounds Coordinate Reference System. Defaults to
epsg:4326. -
reproject_method(WarpResampling, default:'nearest') –WarpKernel resampling algorithm. Defaults to
nearest. -
auto_expand(boolean, default:True) –When True, rioxarray's clip_box will expand clip search if only 1D raster found with clip. When False, will throw
OneDimensionalRastererror if only 1 x or y data point is found. Defaults to True. -
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
-
max_size(int, default:None) –Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio.
-
height(int, default:None) –Output height of the array.
-
width(int, default:None) –Output width of the array.
-
resampling_method(RIOResampling, default:'nearest') –RasterIO resampling algorithm. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
point ¶
point(lon: float, lat: float, coord_crs: CRS = WGS84_CRS, nodata: NoData | None = None, indexes: Indexes | None = None, out_dtype: str | dtype | None = None, **kwargs: Any) -> PointData
Read a pixel value from a dataset.
Parameters:
-
lon(float) –Longitude.
-
lat(float) –Latitude.
-
coord_crs(CRS, default:WGS84_CRS) –Coordinate Reference System of the input coords. Defaults to
epsg:4326. -
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
Returns:
-
PointData–PointData
preview ¶
preview(max_size: int = 1024, height: int | None = None, width: int | None = None, nodata: NoData | None = None, indexes: Indexes | None = None, dst_crs: CRS | None = None, reproject_method: WarpResampling = 'nearest', resampling_method: RIOResampling = 'nearest', out_dtype: str | dtype | None = None, **kwargs: Any) -> ImageData
Return a preview of a dataset.
Parameters:
-
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.
-
height(int, default:None) –Output height of the array.
-
width(int, default:None) –Output width of the array.
-
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
-
dst_crs(CRS, default:None) –target coordinate reference system.
-
reproject_method(WarpResampling, default:'nearest') –WarpKernel resampling algorithm. Defaults to
nearest. -
resampling_method(RIOResampling, default:'nearest') –RasterIO resampling algorithm. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
statistics ¶
statistics(categorical: bool = False, categories: List[float] | None = None, percentiles: List[int] | None = None, hist_options: Dict | None = None, nodata: NoData | None = None, indexes: Indexes | None = None, **kwargs: Any) -> Dict[str, BandStatistics]
Return statistics from a dataset.
tile ¶
tile(tile_x: int, tile_y: int, tile_z: int, tilesize: int = 256, reproject_method: WarpResampling = 'nearest', auto_expand: bool = True, nodata: NoData | None = None, indexes: Indexes | None = None, out_dtype: str | dtype | None = None, **kwargs: Any) -> ImageData
Read a Web Map tile from a dataset.
Parameters:
-
tile_x(int) –Tile's horizontal index.
-
tile_y(int) –Tile's vertical index.
-
tile_z(int) –Tile's zoom level index.
-
tilesize(int, default:256) –Output image size. Defaults to
256. -
reproject_method(WarpResampling, default:'nearest') –WarpKernel resampling algorithm. Defaults to
nearest. -
auto_expand(boolean, default:True) –When True, rioxarray's clip_box will expand clip search if only 1D raster found with clip. When False, will throw
OneDimensionalRastererror if only 1 x or y data point is found. Defaults to True. -
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.