xdem.DEM.get_stats#
- DEM.get_stats(stats_name=None, inlier_mask=None, band=1, counts=None)#
- Overloads:
self, stats_name (str | Callable[[NDArrayNum], np.floating[Any]]), inlier_mask (Raster | NDArrayBool | None), band (int), counts (tuple[int, int] | None) → np.floating[Any]
self, stats_name (list[str | Callable[[NDArrayNum], np.floating[Any]]] | None), inlier_mask (Raster | NDArrayBool | None), band (int), counts (tuple[int, int] | None) → dict[str, np.floating[Any]]
Retrieve specified statistics or all available statistics for the raster data. Allows passing custom callables to calculate custom stats.
Common statistics are :
Mean: arithmetic mean of the data, ignoring masked values.
Median: middle value when the valid data points are sorted in increasing order, ignoring masked values.
Max: maximum value among the data, ignoring masked values.
Min: minimum value among the data, ignoring masked values.
Sum: sum of all data, ignoring masked values.
Sum of squares: sum of the squares of all data, ignoring masked values.
90th percentile: point below which 90% of the data falls, ignoring masked values.
IQR (Interquartile Range): difference between the 75th and 25th percentile of a dataset, ignoring masked values.
LE90 (Linear Error with 90% confidence): difference between the 95th and 5th percentiles of a dataset, representing the range within which 90% of the data points lie. Ignore masked values.
NMAD (Normalized Median Absolute Deviation): robust measure of variability in the data, less sensitive to outliers compared to standard deviation. Ignore masked values.
RMSE (Root Mean Square Error): commonly used to express the magnitude of errors or variability and can give insight into the spread of the data. Only relevant when the raster represents a difference of two objects. Ignore masked values.
Std (Standard deviation): measures the spread or dispersion of the data around the mean, ignoring masked values.
Valid count: number of finite data points in the array. It counts the non-masked elements.
Total count: total size of the raster.
Percentage valid points: ratio between Valid count and Total count.
For all statistics up to and including “Std”, NumPy Masked functions are used (directly or in the calculation) in case of a masked array, NumPy module otherwise.
“Valid count” represents all non zero and not masked pixels in the input data (final_count_nonzero), calculated before the mask application in case of an inlier_mask. NumPy Masked functions are used is this case or if the Raster was already a masked array. “Percentage valid points” is calculated accordingly.
If an inlier mask is passed:
Total inlier count: number of data points in the inlier mask.
Valid inlier count: number of unmasked data points in the array after applying the inlier mask.
Percentage inlier points: ratio between Valid inlier count and Valid count. Useful for classification statistics.
Percentage valid inlier points: ratio between Valid inlier count and Total inlier count.
They are all computed based on the previously stated final_count_nonzero.
Callable functions are supported as well.
- Parameters:
stats_name (
str|Callable[[ndarray[tuple[Any,...],dtype[floating[Any] |integer[Any]]]],floating[Any]] |list[str|Callable[[ndarray[tuple[Any,...],dtype[floating[Any] |integer[Any]]]],floating[Any]]] |None) – Name or list of names of the statistics to retrieve. If None, all statistics are returned. Accepted names include: mean, median, max, min, sum, sum of squares, 90th percentile, iqr, LE90, nmad, rmse, std, valid count, total count, percentage valid points and if an inlier mask is passed : valid inlier count, total inlier count, percentage inlier point, percentage valid inlier points. Custom callables can also be provided.inlier_mask (
Raster|ndarray[tuple[Any,...],dtype[bool]] |None) – Mask or boolean array of areas to include (inliers=True).band (
int) – The index of the band for which to compute statistics. Default is 1.counts (
tuple[int,int] |None) – (number of finite data points in the array, number of valid points (=True, to keep) in inlier_mask), initialize in case of a inlier_mask. DO NOT USE.
- Returns:
The requested statistic or a dictionary of statistics if multiple or all are requested.