Add dem Xarray accessor mirroring DEM class#656
Add dem Xarray accessor mirroring DEM class#656rhugonnet wants to merge 13 commits intoGlacioHack:mainfrom
dem Xarray accessor mirroring DEM class#656Conversation
|
@belletva @marinebcht This PR might remove the short As having a separate volatile This means that we don't need a specific To give you an idea of how it looks for
The "problem" is that, if no vertical CRS is defined, the CRS simply displays as a classic CRS (no "horizontal" and "vertical"). If we think that is too implicit, I could be convinced of keeping our What do you think? |
|
@belletva @adehecq @adebardo @marinebcht This PR is pretty much done: All tests passing locally. You can also review, and we'll be able to merge once a new GeoUtils is released. To avoid big conflicts, it'll be better to merge this first, then the coregistration/uncertainty PR #759, then change the internal structure of some |
|
Yes, you right, as the Plus, the idea to correct the error reported in GlacioHack/geoutils#805 (dataset 2) is to move the componed crs treatment into geoutils to handle CRSs when have directly a vertical axis. My only suggestion s about your last point (crs with no vertical axis that I have mention in #805), either we print classical EPSG:XXXX for exemple or we print [ EPSG:XXXX, None ]. Perhaps, we could add a |
This PR adds the
demXarray accessor mirroring theDEMclass, since the finalization of therstaccessor in GlacioHack/geoutils#446, and Dask/Multiproc support for terrain attributes and vertical CRS transformation.More complex implementations (coregistration, uncertainty analysis) will be done in separate PRs.
The accessor allows to access all attributes and run all methods already implemented for DEMs from a
xarray.DataArrayobject (e.g.,ds.dem.slope(),ds.dem.coregister_3d()), including functionalities from rasters inherited from therstaccessor (e.g.,ds.dem.reproject()).The setup follows a double inheritance between the
RasterAccessorandDEMBase, so that thedemaccessor can also runreproject(), etc.Resolves #392
Resolves #370
Resolves #933
Resolves #934
Resolves #935
Summary of changes
To understand the changes below, first see changes related to the
rstaccessor in GeoUtils: GlacioHack/geoutils#446As for the
rstaccessor, most of the contents of theDEMclass are moved into aDEMBaseparent class, inherited by both theDEMclass anddemaccessor class.In this case, however, inheritance is more delicate because
DEMalso needs to inherit functionalities fromRaster(that are not inRasterBase) and thedemaccessor needs to inherit functionalities fromrst(that are not inRasterBaseeither).Therefore, the
DEMclass has dual-inheritance ofRasterandDEMBase, while thedemaccessor has dual inheritance ofrstandDEMBase. This makes things slightly more complex when explicitly callingsuper(), 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_arrayfunctions allow to return a same-class object. In this case, onlyDEMneeds to override with its ownfrom_array(asdemalready returns axarray.DataArraythroughrst).TO-DO
Code
to_vcrs,DEMBase,DEMAccessor,Other Dask support to add
Mostly left is to add Dask support to coregistration and uncertainty analysis (both heteroscedasticity and variography/autocorrelation). This is related to old #525, and will be facilitated by ongoing #759