Open mauriciovancine opened 1 year ago
Thanks for your interest!
"river" objects are lists containing spatial information at various aggregation levels. Essentially, sub-list "FD" contains information at the pixel level; "RN" pertains to pixels belonging to the channelized river network; "AG" corresponds to the reach level; and "SC" identifies the subcatchment level.
You can read more about the structure of "river" objects in the documentation of functions OCNet::create_OCN and OCNet::landscape_OCN. The output of function extract_river is equivalent to that of OCNet::landscape_OCN. Note that, in the CRAN version of OCNet, the objects produced are simply lists and there is no definition of a S4 class--but their structure is actually the same and I plan to introduce the "river" class in OCNet with the next CRAN update. The current GitHub version of OCNet already features the "river" class.
Thank you so much @lucarraro .
I will test here.
Best regards.
@mauriciovancine , I ran into the same issue but with the catchments ("CM" in the river class). It required some digging into how the object is stored, but it is pretty easy and fast to take the information and make it into an object that the package sf can recognize. This manipulation of the geometry allows one to plot the result in things like leaflet or mapview with other spatial objects. Below is the code I used to get the catchment. note that r is my river object.
o<-unlist(r$CM)
xs<-o[ grepl( "XContour" , names( o ) ) ] ys<-o[ grepl( "YContour" , names( o ) ) ]
raw_shed_coords<-data.frame(xs,ys)
names(raw_shed_coords)<-c('X','Y');row.names(raw_shed_coords)<-NULL
sf_shed <- raw_shed_coords %>% st_as_sf(coords = c("X", "Y"), crs = 4269) %>% summarise(geometry = st_combine(geometry)) %>% st_cast("POLYGON")
Dear @lucarraro,
Congratulations on the package.
I tested it here, and it worked great (after spending some time compiling TrauDEM on GNU/Linux).
I would like to know if there is a way to access the spatial data of the “river” class?
Thanks.
Yours sincerely.