GlacioHack / xdem

Analysis of digital elevation models (DEMs)
https://xdem.readthedocs.io/
Apache License 2.0
149 stars 41 forks source link

[POC] add missing stats #660

Open adebardo opened 1 week ago

adebardo commented 1 week ago

Context

It is essential for current users of demcompare, such as QI or IGN, to have a quick and concise way of obtaining a wide range of basic metrics when performing DEM analysis. This ticket aims to address this need.

Although it is clear that, thanks to its ability to work with rasters and its coupling with NumPy for basic metric calculations, we must ensure that these metrics are easy to manipulate, retrieve, and potentially process, especially for automation tasks like implementing a CLI.

Implementation

:warning: This ticket will be created under the XDEM project, but the developments will be carried out in geoutils.

We propose creating a get_metrics() function in the raster module.

get_metrics(self, metrics_list: list = None):

If None: 
    Returns the full dictionary of global metrics.
If metrics_list: 
    Iterate through it and build the dictionary accordingly.

return metrics_dict

Example usage:

dem = load(dem)
metrics_dict = dem.get_metrics(["mean", "nmad", "rmse"])

:warning: This function should be callable within the .info() method of the DEM.

List of metrics:

:warning: We need to discuss the NMAD implementation in xDEM.

Tests

Add tests for the get_metrics() function:

Additionally, verify the behavior of the .info() method.

Documentation

Update the documentation for both geoutils and xDEM to include this new functionality.

Internal Testing

Ensure that it works seamlessly with xDEM.

Estimation

3 days

adebardo commented 4 days ago

@rhugonnet @duboise-cnes :)

rhugonnet commented 3 days ago

Looks good! Link to our previous discussion: https://github.com/GlacioHack/geoutils/issues/602 (forgot it was in GeoUtils).

I only have a couple main remarks:

Other small remarks:

And I really like the idea of this function behind called in info() for consistency!

duboise-cnes commented 2 days ago

Not so much to add to @rhugonnet comments, already large ;) Ok for statistic vs metric naming, or even stat would do for me if consistent with naming conventions in xdem. No problem to get something more accurate and expressive.

Other question: where is the status of more complex demcompare metric or stats for non scalar element such as hillshade, svf . I remember the discussion that a structure in xdem would be better to automate more "stats" possibilities than only scalar and to put the metric structure in xdem then. My question: will it be possible to automate other type of "metric"/stat such as PDF, CDF, hillshide through a pipeline with a common unified interface ? afterwards but to be sure nothing will block. Hoping I am clear.

thanks for the work