Skip to content

Commit

Permalink
docs: add get_stats() in raster class documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vschaffn committed Dec 13, 2024
1 parent 02df716 commit 4e0125b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doc/source/raster_class.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,31 @@ rast_reproj.to_pointcloud()
# Export to xarray data array
rast_reproj.to_xarray()
```

## Obtain Statistics
The `get_stats()` method allows to extract key statistical information from a raster in a dictionary.
Supported statistics are : mean, median, max, mean, sum, sum of squares, 90th percentile, nmad, rmse, std.
Callable functions are supported as well.

### Usage Examples:
- Get all statistics in a dict:
```{code-cell} ipython3
rast.get_stats()
```

- Get a single statistic (e.g., 'mean') as a float:
```{code-cell} ipython3
rast.get_stats("mean")
```

- Get multiple statistics in a dict:
```{code-cell} ipython3
rast.get_stats(["mean", "max", "rmse"])
```

- Using a custom callable statistic:
```{code-cell} ipython3
def custom_stat(data):
return np.nansum(data > 100) # Count the number of pixels above 100
rast.get_stats(custom_stat)
```

0 comments on commit 4e0125b

Please sign in to comment.