any_raster_to_xr_ds#
- any_raster_to_xr_ds(function: Callable) Callable [source]#
Allows a function to ingest AnyRasterType and convert it into a xr.DataArray:
a path (
Path
,CloudPath
orstr
)a
xarray.Dataset
or axarray.DataArray
a
rasterio.DatasetWriter
orrasterio.DatasetReader
rasterio
dataset after reading, its array and metadata: (np.ndarray, dict)
- Parameters:
function (Callable) – Function to decorate
- Returns:
decorated function
- Return type:
Callable
Examples
>>> # Create mock function >>> @path_or_dst >>> def fct(ds): >>> read(ds) >>> >>> # Test the two ways >>> read1 = fct("path/to/raster.tif") >>> with rasterio.open("path/to/raster.tif") as ds: >>> read2 = fct(ds) >>> >>> # Test >>> read1 == read2 True