raster_tools.Raster.reclassify#
- Raster.reclassify(remapping, unmapped_to_null=False)[source]#
Reclassify raster values based on a mapping.
The raster must have an integer type.
- Parameters
remapping (str, dict) – Can be either a
dict
or a path string. If adict
is provided, the keys will be reclassified to the corresponding values. It is possible to map values to the null value by providingNone
in the mapping. If a path string, it is treated as an ASCII remap file where each line looks likea:b
anda
andb
are scalars.b
can also be “NoData”. This indicates thata
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 isFalse
.
- Returns
The remapped raster.
- Return type