- read(ds: ~typing.Union[str, tuple, ~rasterio.io.DatasetReader], resolution: ~typing.Union[tuple, list, float] = None, size: ~typing.Union[tuple, list] = None, window: ~typing.Any = None, resampling: ~rasterio.enums.Resampling = Resampling.nearest, masked: bool = True, **kwargs) -> (<class 'numpy.ma.core.MaskedArray'>, <class 'dict'>)[source]#
Read a raster dataset from a
rasterio.Datasetor a path.
The resolution can be provided (in dataset unit) as:
a tuple or a list of (X, Y) resolutions
a float, in which case X resolution = Y resolution
None, in which case the dataset resolution will be used
Tip: Use index with a list of one element to keep a 3D array
>>> raster_path = "path/to/raster.tif" >>> raster1, meta1 = read(raster_path) >>> # or >>> with rasterio.open(raster_path) as ds: >>> raster2, meta2 = read(ds) >>> raster1 == raster2 True >>> meta1 == meta2 True
ds (PATH_ARR_DS) – Path to the raster, its dataset, its
xarrayor a tuple containing its array and metadata
resolution (Union[tuple, list, float]) – Resolution of the wanted band, in dataset resolution unit (X, Y)
size (Union[tuple, list]) – Size of the array (width, height). Not used if resolution is provided.
window (Any) – Anything that can be returned as a window. In case of iterable, assumption is made it’s geographic bounds. For pixel, please provide a Window directly.
resampling (Resampling) – Resampling method (nearest by default)
masked (bool) – Get a masked array,
Trueby default (whereas it is False by default in rasterio)
**kwargs – Other ds.read() arguments such as indexes.
Masked array corresponding to the raster data and its meta data
- Return type: