georastertools package

Subpackages

Submodules

georastertools.filtering module

georastertools.georastertools module

georastertools.hillshade module

georastertools.main module

georastertools.radioindice module

georastertools.speed module

georastertools.svf module

georastertools.tiling module

georastertools.timeseries module

georastertools.utils module

This module defines several utility methods for:

  • handling path

  • transforming data

  • computing sliding windows

georastertools.zonalstats module

Module contents

This module defines the base class for every Rastertool, namely eolab.georastertools.Rastertool.

It also defines a specific Exception class that shall be raised when invalid rastertool’s configuration parameters are setup.

Finally, it defines additional decorator classes that factorize some rastertool configuration features. For example, the class eolab.georastertools.Windowable enables to configure a rastertool with windowable capabilities (i.e. capability to split the raster input file in small parts in order to distribute the processing over several cpus).

class georastertools.Rastertool[source]

Bases: ABC

Base class for every raster tool which contains the common configuration:

  • the output dir where to store the results (by default, current dir)

  • whether to save to disk the intermediate VRT images that can be created when handling the input raster products (that can be an archive of several band files for example). This parameter is mainly for debug purpose and is False by default.

property keep_vrt: bool

Whether intermediate VRT images shall be kept

property outputdir: str

Path of the output directory where are stored the results

postprocess_files(inputfiles: List[str], outputfiles: List[str]) List[str][source]

Run a postprocess when all input files have been processed. This step may consist in transforming the outputs or mixing them to generate additional ones.

Note

This implementation does nothing. Override this method in the subclass to achieve special processing that needs the whole list of inputfiles and/or the output files generated when processing every single file (to mix them for instance).

Parameters:
  • inputfiles ([str]) – Input images to process

  • outputfiles ([str]) – List of generated files after executing the rastertool on the input files

Returns

[str]: Additional output files (by default empty list)

process_file(inputfile: str) List[str][source]

Run the rastertool to a single input file.

Note

This implementation does nothing. Override this method in the subclass to achieve special processing of an inputfile.

Parameters:

inputfile (str) – Input image to process

Returns:

List of generated files (by default empty list)

Return type:

[str]

process_files(inputfiles: List[str])[source]

Run the rastertool to a set of input files. By default, this implementation recursively calls “process_file” on each input file and then calls “postprocess_files”.

Note

It is not meant to be overriden by subclasses. Prefer overriding process_file and postproces_files instead.

Parameters:

inputfiles ([str]) – Input images to process

Returns:

([str]) The list of the generated files

property vrt_dir: str

Dir where to store intermediate VRT images

with_output(outputdir: str = '.')[source]

Set up the output.

Parameters:

outputdir (str, optional, default=".") – Output dir where to store results. If none, it is set to current dir

Returns:

The current instance so that it is possible to chain the with… calls (fluent API)

Return type:

eolab.georastertools.Rastertool

with_vrt_stored(keep_vrt: bool)[source]

Configure if the intermediate VRT images that are generated when handling the input files (which can be complex raster product composed of several band files) shall be stored to disk or not - for debug purpose for instance.

Parameters:

keep_vrt (bool) – Whether intermediate VRT images shall be stored or not

Returns:

The current instance so that it is possible to chain the with… calls (fluent API)

Return type:

eolab.georastertools.Rastertool

exception georastertools.RastertoolConfigurationException(message, exit_code=2)[source]

Bases: Exception

This class defines an exception that is raised when the configuration of the raster tool is invalid (wrong input parameter)

class georastertools.Windowable[source]

Bases: object

Decorator of a eolab.georastertools.Rastertool that adds configuration parameters to set the windowable capability of the tool:

  • the window size

  • the mode for padding the window when at the edge of the image

property pad_mode: str

//numpy.org/doc/stable/reference/generated/numpy.pad.html>`_ the image when the window is on the edge of the image The mode can be self defined or among [constant (default), edge, linear_ramp, maximum, mean, median, minimum, reflect, symmetric, wrap, empty].

Type:

Mode used to `pad <https

property window_size: int

Size of the windows to split the image in small parts

with_windows(window_size: int = 1024, pad_mode: str = 'edge')[source]

Configure the window generation for processing image

Parameters:
  • window_size (int, optional, default=1024) – Size of windows for splitting the processed image in small parts so that processing can be distributed on several cpus.

  • pad_mode (str, optional, default="edge") – Mode for padding data around the windows that are on the edge of the image. See https://numpy.org/doc/stable/reference/generated/numpy.pad.html

Returns:

The current instance so that it is possible to chain the with… calls (fluent API)

Return type:

eolab.georastertools.Rastertool