The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Querying flow information

Jemma Stachelek

2023-08-11

Let’s get some flow data for the NHDPlus subset included with nhdR package. Our goal is to adjust the color and size of each reach by their average flow.

library(nhdR)
library(dplyr)
library(ggplot2)
library(sf)
ggplot() +
  geom_sf(data = gull$sp$NHDWaterbody) +
  geom_sf(data = gull$sp$NHDFlowLine)
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()


gull_sf <- gull$sp$NHDFlowLine

NHDPlus includes two estimates of flow:

Enhanced Unit Runoff Method (EROM)

eromflow  <- nhd_plus_load(4, "EROMExtension", "EROM_MA0001") %>%
  filter(ComID %in% gull$sp$NHDFlowLine$COMID) %>%
  select(ComID, Q0001F)

gull_sf <- left_join(gull_sf, eromflow, by = c("COMID" = "ComID"))

Vogel Flow Estimation

vogelflow  <- nhd_plus_load(4, "VogelExtension", "vogelflow") %>%
  filter(COMID %in% gull$sp$NHDFlowLine$COMID,
    MAFLOWV != -9999.00000)

gull_sf <- left_join(gull_sf, vogelflow, by = "COMID")

Visualization

gull_sf <- dplyr::filter(gull_sf, !is.na(Q0001F))
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
gull_sf %>%
  ggplot() +
  geom_sf(data = gull$sp$NHDWaterbody) +
  geom_sf(aes(color = gull_sf$Q0001F), size = gull_sf$Q0001F / 20) +
  labs(color = "EROM Flow (cms)")
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> Warning: Use of `gull_sf$Q0001F` is discouraged.
#> ℹ Use `Q0001F` instead.


gull_sf <- filter(gull_sf, !is.na(MAFLOWV))
gull_sf %>%
  ggplot() +
  geom_sf(data = gull$sp$NHDWaterbody) +
  geom_sf(aes(color = gull_sf$MAFLOWV), size = gull_sf$MAFLOWV / 20) +
  labs(color = "Vogel Flow (cms)")
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> Warning: Use of `gull_sf$MAFLOWV` is discouraged.
#> ℹ Use `MAFLOWV` instead.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.