lucarraro / rivnet

An R-package allowing seamless extraction of river networks from Digital Elevation Models data
https://lucarraro.github.io/rivnet/
Other
13 stars 1 forks source link

covariate_river run time #6

Open tanharri opened 6 months ago

tanharri commented 6 months ago

Hi,

I am trying to use the function covariate_river to attach the values of a covariate to a river network. The runtime of this function seems to be exceptionally long. I was wondering if this would be expected given the size and structure of the river network, and whether there is a faster solution.

For example, given the way the covariates are attached in the edith vignette https://cran.r-project.org/web/packages/eDITH/vignettes/eDITH.html

Could I extract an average along the aggregated vertices and attach them similarly to how elev is incorporated? And in that sense, is SC equivalent to AG, given that the river object must be aggregated to run covariate_river?

Cheers

rivnet::covariate_river(my_covar, river, categorical = categorical)

my_covar class : SpatRaster dimensions : 1074, 1345, 1 (nrow, ncol, nlyr) resolution : 100.2776, 100.2776 (x, y) extent : 277070.7, 411944.2, 753964.1, 861662.3 (xmin, xmax, ymin, ymax) coord. ref. : OSGB36 / British National Grid source(s) : memory name : landcover min value : 111 max value : 523

river Class : river Type : Real river No. FD nodes : 1224671 Dimensions : 2685 x 1113 Cell size : 41.65 Has elevation : TRUE Aggregated : TRUE Threshold area : 4249300.54 Max reach length: Inf No. RN nodes : 14893 No. AG nodes : 265 Has paths : FALSE River geometry : TRUE

lucarraro commented 6 months ago

Hi,

I haven't tested covariate_river for very large river networks, so I cannot say much about its runtime in such cases. If you don't mind, I could have a look at your script and see whether there's a way to improve the function's speed. You can find my e-mail in the package description.

As for your further questions, I'm not quite sure I fully understood them. Probably, some more context on what your goal is would help. Anyways, you can indeed attach objects to an existing river object. SC is equivalent to AG in the sense that there's a 1:1 correspondence between the two levels (for each reach there's a respective subcatchment).

Cheers, Luca