makepath / xarray-spatial

Raster-based Spatial Analytics for Python
https://xarray-spatial.readthedocs.io/
MIT License
805 stars 81 forks source link

Classification tools: return ranges of classes #752

Closed thuydotm closed 1 year ago

thuydotm commented 1 year ago

xarray-spatial classification tools currently return DataArray of classified data. It would be helpful if we can also return the range of each class. This can be obtained by adding a new boolean input param get_ranges to each function. For example, with natural_breaks, the new interface should looks like:

from xrspatial.classify import natural_breaks
# return both ranges of classes and the classified data array if `get_ranges=True`
# class_ranges is a list of numeric values with `len(class_ranges)=k`, `k` is the number of classes.
# class `i` has a range from `class_ranges[i]` to `class_range[i+1]`
# range of class `k-1` is simply not less than `class_range[k-1]`
class_ranges, classified_data = natural_breaks(data, k=10, get_ranges=True)
# (default) only return the data array of classified data when `get_ranges=False`
classified_data = natural_breaks(data, k=10, get_ranges=False)
thuydotm commented 1 year ago

Will not implement. Closing.