RSGISLib Maths Tools
Conversion
- rsgislib.tools.maths.round_to_nearest_val(input_val: array | int | float | List[int] | List[float], round_val: int = 1, round_direction: int = 1)
Rounds elements of a NumPy array to the nearest multiple of the value specified, with options for rounding up, down or to the nearest value. For example, if a round_val of 5 is provided then the numbers will be rounded to intervals of 5.
- Parameters:
input_val – A NumPy array of numbers.
round_val – The value by which the input is to be rounded to.
round_direction – Specify the round direction (rsgislib.ROUND_NEAREST, rsgislib.ROUND_UP, or rsgislib.ROUND_DOWN). The default is rsgislib.ROUND_NEAREST.
- Returns:
a single value or a numpy array of the rounded values.