classify#
- classify(raster: DataArray, bins: list, values: list, right: bool = False, new_name: str | None = None) DataArray[source]#
Classify a raster according to the given bin edges and its corresponding values.
Example of usecase: classifying a fire severity.
- Parameters:
raster (xr.DataArray) – Raster to classify
bins (list) – Bin edges. Should be monotonic.
values (list) – Values to set for each bin. There should be one value more than the number of bins.
right (bool) – Indicating whether the intervals include the right or the left bin edge. Default behavior is (right==False) indicating that the interval does not include the right edge. The left bin end is open in this case, i.e., bins[i-1] <= x < bins[i] is the default behavior for monotonically increasing bins.
new_name (str) – New name to be set
- Returns:
Classified raster
- Return type:
xr.DataArray
Examples
>>> dnbr = rasters.read(r"dNBR.tif") >>> fire_severity = classify(dnbr, [0.27, 0.66], [2, 3, 4])