Skip to content

Commit 6ec6840

Browse files
committed
address hydroloom issue in sort_network
1 parent 97a796b commit 6ec6840

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

R/hfsubsetR-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#' @importFrom nhdplusTools discover_nhdplus_id get_sorted
1212
#' @importFrom jsonlite toJSON
1313
#' @importFrom glue glue
14-
#' @importFrom dplyr tbl select mutate rename if_any filter everything distinct collect any_of `%>%`
14+
#' @importFrom dplyr tbl select mutate rename if_any filter everything distinct collect any_of `%>%` pull
1515
#' @importFrom arrow open_dataset
1616
#' @importFrom httr GET progress write_disk
1717
NULL

R/query_subset.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@ query_subset <- function(query) {
2424
dplyr::select(dplyr::any_of(c("id", "toid", "divide_id", "poi_id"))) |>
2525
dplyr::distinct() |>
2626
dplyr::collect()
27-
28-
topology <- suppressWarnings(nhdplusTools::get_sorted(network, outlets = origin$toid))
27+
28+
topology <- suppressWarnings(
29+
nhdplusTools::sort_network(dplyr::select(network, 'id', 'toid'),
30+
outlets = origin$toid)
31+
)
2932

3033
topology$toid[nrow(topology)] <- NA
34+
35+
topology <- as.matrix(topology)
36+
topology <- topology[!is.na(topology)]
3137

3238
all_identifiers <-
33-
as.matrix(topology) |>
39+
filter(network, id %in% topology) |>
40+
as.matrix() |>
3441
as.vector() |>
3542
unique()
3643

37-
all_identifiers <-
38-
all_identifiers[!is.na(all_identifiers)]
44+
all_identifiers <- all_identifiers[!is.na(all_identifiers)]
3945

4046
if('lakes' %in% query$layers){
4147
lake_id <- net |>
@@ -57,6 +63,7 @@ query_subset <- function(query) {
5763
query_extract(query)
5864
}
5965

66+
6067
#' Perform data extraction from a query
6168
#' @param query A `hfsubset_query` object
6269
#' @returns A list of hydrofabric layers, or the path to the sink of the query

0 commit comments

Comments
 (0)