get the band with the maximum value from a xarray stack

17 Views Asked by At

So, I have 3 rasters stacked in xarray. They represent classes. I want to get which class has the max value in order to assign it a specific class.

Stacked raster: stacked_rasters = xr.concat([raster_one, raster_two, raster_three], dim="Classes")

Now I know how to get the maximum value: max_value_raster = stacked_rasters.max(dim="Classes")

But I really want to get which of the 3 rasters has the maximum value and classify the final raster based on its name. Any thoughts on how I could accomplish this?

0

There are 0 best solutions below