Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dem Xarray accessor mirroring DEM class #656

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rhugonnet
Copy link
Member

@rhugonnet rhugonnet commented Nov 21, 2024

This PR adds the dem Xarray accessor mirroring the DEM class. Relies on GlacioHack/geoutils#446.

The accessor allows to access all attributes and run all methods already implemented for DEMs from a xarray.DataArray object (e.g., ds.dem.slope(), ds.dem.coregister_3d()), including functionalities from rasters inherited from the rst accessor (e.g., ds.dem.reproject()).

It also opens up the opportunity to easily add Dask support to run our functionalities out-of-memory. This links to ongoing work in #525 for coregistration, which is one of the most complex applications. For vertical transformation and terrain attributes, we should be able to easily add support using dask.map_overlap().

Resolves #392

Summary of changes

To understand the changes below, first see changes related to the rst accessor in GeoUtils: GlacioHack/geoutils#446

As for the rst accessor, most of the contents of the DEM class are moved into a DEMBase parent class, inherited by both the DEM class and dem accessor class.

In this case, however, inheritance is more delicate because DEM also needs to inherit functionalities from Raster (that are not in RasterBase) and the dem accessor needs to inherit functionalities from rst (that are not in RasterBase either).
Therefore, the DEM class has dual-inheritance of Raster and DEMBase, while the dem accessor has dual inheritance of rst and DEMBase. This makes things slightly more complex when explicitly calling super(), which is only needed in a few occurences of core functions or __init__, but otherwise easy for other functionalities!

Similar as for the GeoUtils PR, the from_array functions allow to return a same-class object. In this case, only DEM needs to override with its own from_array (as dem already returns a xarray.DataArray through `rst).

TO-DO

Code

  • Make Coreg.fit() support Xarray input, in link with Dask for coregistration #525,
  • Make DEM.estimate_uncertainty() support Xarray input,
  • Ensure dual support of masked arrays and NaN arrays for all DEM methods,
  • Add delayed function for "easy cases": all terrain attributes and to_vcrs,
  • Add tests specific to DEMBase,
  • Add tests specific to DEMAccessor.

Documentation

  • Update page "The digital elevation model" with accessor,
  • Update all pages with DEM.function() to DEM.function() or ds.dem.function(),
  • Update API,
  • Update Quick start,
  • Add page "Dask support" listing all functionalities supported out-of-memory.

Other Dask support to add (will be moved as issues for other PRs)

  • Finalize Dask support within coregistration (Dask for coregistration #525),
  • Add Dask support for uncertainty analysis, heteroscedasticity: add subsampling to nd_binning and use the delayed subsample of GeoUtils,
  • Add Dask support for uncertainty analysis, variography: add specific log-distance subsampling as Dask-delayed to xDEM, or SciKit-GStat?

@rhugonnet rhugonnet marked this pull request as draft November 21, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Xarray accessor dem
1 participant