raster_tools.general.reclassify#

raster_tools.general.reclassify(raster, remapping, unmapped_to_null=False)[source]#

Reclassify the input raster values based on a mapping.

Parameters
  • raster (str, Raster) – The input raster to reclassify. Can be a path string or Raster object.

  • remapping (str, dict) – Can be either a dict or a path string. If a dict is provided, the keys will be reclassified to the corresponding values. It is possible to map values to the null value by providing None in the mapping. If a path string, it is treated as an ASCII remap file where each line looks like a:b and a and b are scalars. b can also be “NoData”. This indicates that a will be mapped to the null value. The output values of the mapping can cause type promotion. If the input raster has integer data and one of the outputs in the mapping is a float, the result will be a float raster.

  • unmapped_to_null (bool, optional) – If True, values not included in the mapping are instead mapped to the null value. Default is False.

Returns

The remapped raster.

Return type

Raster