raster_tools.general.remap_range#

raster_tools.general.remap_range(raster, mapping, inclusivity='left')[source]#

Remaps values based on a mapping or list of mappings.

Mappings are applied all at once with earlier mappings taking precedence.

Parameters
  • raster (Raster or str) – Path string or Raster to perform remap on.

  • mapping (3-tuple of scalars or list of 3-tuples of scalars) – A tuple or list of tuples containing (min, max, new_value) scalars. The mappiing(s) map values between the min and max to the new_value. If new_value is None, the matching pixels will be marked as null. If mapping is a list and there are mappings that conflict or overlap, earlier mappings take precedence. inclusivity determines which sides of the range are inclusive and exclusive.

  • inclusivity (str, optional) –

    Determines whether to be inclusive or exclusive on either end of the range. Default is ‘left’.

    ’left’ [min, max)

    Left (min) side is inclusive and right (max) side is exclusive.

    ’right’ (min, max]

    Left (min) side is exclusive and right (max) side is inclusive.

    ’both’ [min, max]

    Both sides are inclusive.

    ’none’ (min, max)

    Both sides are exclusive.

Returns

The resulting Raster.

Return type

Raster