path_arr_dst

Contents

path_arr_dst#

path_arr_dst(function: Callable) Callable[source]#

Path, xarray, (array, metadata) or dataset decorator. Allows a function to ingest:

  • a path

  • a xarray

  • a rasterio dataset

  • rasterio open data: (array, meta)

Parameters:

function (Callable) – Function to decorate

Returns:

decorated function

Return type:

Callable

Example

>>> # 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