remotior_sensus.tools.band_combination module

Band combination.

This tool is intended for combining classifications in order to get a raster where each value corresponds to a combination of class values. A unique value is assigned to each combination of values. The output is a raster made of unique values corresponding to combinations of values. An output text file describes the correspondence between unique values and combinations, as well as the statistics of each combination.

Typical usage example:

>>> # import Remotior Sensus and start the session
>>> import remotior_sensus
>>> rs = remotior_sensus.Session()
>>> # start the process
>>> combination = rs.band_combination(input_bands=['path_1', 'path_2'],
... output_path='output_path')
remotior_sensus.tools.band_combination.band_combination(input_bands: list | int | BandSet, output_path: None | str = None, nodata_value: None | int = None, overwrite: bool | None = False, n_processes: None | int = None, available_ram: None | int = None, bandset_catalog: BandSetCatalog | None = None, extent_list: list | None = None, column_name_list: list | None = None, output_table: bool | None = True, progress_message: bool | None = True) OutputManager

Calculation of band combination.

This tool allows for the combination of rasters or bands loaded in a BandSet. This tool is intended for combining classifications in order to get a raster where each value corresponds to a combination of class values. Input raster values must be integer type. The output is a combination raster and a text file reporting the statistics of each combination.

Parameters:
  • input_bands – list of paths of input rasters, or number of BandSet, or BandSet object.

  • output_path – path of the output raster.

  • overwrite – if True, output overwrites existing files.

  • nodata_value – input value to be considered as nodata.

  • n_processes – number of parallel processes.

  • available_ram – number of megabytes of RAM available to processes.

  • bandset_catalog – BandSetCatalog object required if input_bands is a BandSet number.

  • extent_list – list of boundary coordinates left top right bottom.

  • column_name_list – list of strings corresponding to input bands used as column names in output table, if None then column names are extracted for input band names.

  • output_table – if True then calculate output table; if False then calculate only array of combinations and sum.

  • progress_message – if True then start progress message; if False does not start the progress message (useful if launched from other tools).

Returns:

If output_table is True returns the OutputManager() object with
  • paths = [output raster path, output table path]

If output_table is False returns the OutputManager() object with
  • paths = [virtual raster path]

  • extra = {‘combinations’: array of combinations, ‘sums’: array of the sums of values}

Examples

Combination using two rasters having paths path_1 and path_2
>>> combination = band_combination(input_bands=['path_1', 'path_2'],output_path='output_path')
The combination raster and the table are finally created; the paths can be retrieved from the output that is an OutputManager() object
>>> raster_path, table_path = combination.paths
>>> print(raster_path)
output_path
Combination using a virtual raster as output file
>>> combination = band_combination(input_bands=['path_1', 'path_2'],output_path='output_path.vrt')
>>> raster_path, table_path = combination.paths
>>> print(raster_path)
output_path.vrt
Using input BandSet number
>>> catalog = BandSetCatalog()
>>> combination = band_combination(input_bands=1,output_path='output_path',bandset_catalog=catalog)
Using input BandSet
>>> catalog = BandSetCatalog()
>>> combination = band_combination(input_bands=catalog.get_bandset(1),output_path='output_path')