Learn R Programming

nhdplusTools (version 0.3.8)

get_DM: Navigate Downstream Mainstem

Description

Traverse NHDPlus network downstream main stem

Usage

get_DM(network, comid, distance = NULL)

Arguments

network

data.frame NHDPlus flowlines including at a minimum: COMID, LENGTHKM, DnHydroseq, and Hydroseq.

comid

integer identifier to start navigating from.

distance

numeric distance in km to limit how many COMIDs are returned. The COMID that exceeds the distance specified is returned.

Value

integer vector of all COMIDs downstream of the starting COMID along the mainstem.

Examples

Run this code
# NOT RUN {
library(sf)
sample_flines <- read_sf(system.file("extdata",
                                     "petapsco_flowlines.gpkg",
                                     package = "nhdplusTools"))
plot(sample_flines$geom)
start_COMID <- 11690092
DM_COMIDs <- get_DM(sample_flines, start_COMID)
plot(dplyr::filter(sample_flines, COMID %in% DM_COMIDs)$geom,
     col = "red", add = TRUE, lwd = 3)

DM_COMIDs <- get_DM(sample_flines, start_COMID, distance = 40)
plot(dplyr::filter(sample_flines, COMID %in% DM_COMIDs)$geom,
     col = "blue", add = TRUE, lwd = 2)


# }

Run the code above in your browser using DataLab