eobox.raster.rasterprocessing

class eobox.raster.rasterprocessing.MultiRasterIO(layer_files: list, dst_res: Optional[float] = None, downsampler: str = 'average', upsampler: str = 'nearest')[source]

Bases: object

Read, process and write multiple single layer raster files.

Parameters
  • {list} -- List of paths to single band raster files. (layer_files) –

  • {float} -- Destination resolution. If None it is set to the highest resolution of all layers. (dst_res) –

Keyword Arguments
  • {numeric} -- Destination resolution in which to return the array. (dst_res) – If None, each layer is returned in its native resolution, else each layer is resampled to the destination resolution dst_res (default: {None}).

  • {str} -- The method used for downsampling layers with higher (downsampler) – raster cell size (default: {‘average’}).

  • {str} -- The method used for upsampling layers with lower (upsampler) – raster cell size (default: {‘nearest’})

apply_and_save(dst_files, func, **kwargs)[source]
block_windows(res=None)[source]

Load windows for chunks-wise processing from raster internal tiling (first raster of given resolution).

Parameters

{numeric} -- Resolution determining the raster (res) –

get_arrays(ji_win)[source]

Get the data of the a window given the ji_windows derived with :method:`ji_windows`.

Parameters

{[type]} -- The index of the window or the (ji_win) –

Returns

(list of) array(s) – List of 2D arrays in native resolution in case dst_res is None

or a 3D array where all layers are resampled to dst_res resolution.

get_window_from_xy(xy)[source]

Get the window index given a coordinate (raster CRS).

ji_windows(ij_win)[source]

For a given specific window, i.e. an element of windows, get the windows of all resolutions.

Parameters

{int} -- The index specifying the window for which to return the resolution-windows. (ij_win) –

windows_df()[source]

Get Windows (W) W-row, W-col and W-index of windows e.g. loaded with block_windows() as a dataframe.

Returns

[dataframe] – A dataframe with the window information and indices (row, col, index).

windows_from_blocksize(blocksize_xy=512)[source]

Create rasterio.windows.Window instances with given size which fully cover the raster.

Parameters

{int or list of two int} -- Size of the window. If one integer is given it defines (blocksize_xy) – the width and height of the window. If a list of two integers if given the first defines the width and the second the height.

Returns

None – But the attributes windows, windows_row and windows_col are updated.

eobox.raster.rasterprocessing.create_distance_to_raster_border(src_raster, dst_raster, maxdist=None, overwrite=False)[source]

Create a raster with pixels values being the distance to the raster border (pixel distances).

eobox.raster.rasterprocessing.window_from_window(window_src, transform_src, transform_dst)[source]
eobox.raster.rasterprocessing.windows_from_blocksize(blocksize_xy, width, height)[source]

Create rasterio.windows.Window instances with given size which fully cover a raster.

Parameters
  • {int or list of two int} -- [description] (blocksize_xy) –

  • {int} -- With of the raster for which to create the windows. (width) –

  • {int} -- Heigth of the raster for which to create the windows. (height) –

Returns

list – List of windows according to the following format

[[<row-index>, <column index>], rasterio.windows.Window(<col_off>, <row_off>, <width>, <height>)].