Open rburghol opened 2 years ago
# get outlet, known comid (point above beaver creek in Rivanna/Mechums)
bct <- nhdplusTools::get_nhdplus(comid='8567219')
# this gets tonode/fromnode, but I am unfamiliar with the number scheme, what is it referring to? It;s not a comid...
bct$fromnode
# [1] 200061236
bct$tonode
# [1] 200061237
# How to get next down comid?
# get next up?
# this does not work
nhdplusTools::get_tocomid(bct)
# Error in `rename()`:
# ! Names must be unique.
# ✖ These names are duplicated:
# * "id" at locations 1 and 2.
# Run `rlang::last_error()` to see where the error occurred.
# this also fails, though it avoids an error, since hte comid is the same as requesting feature, and tocomid is 0
nhdplusTools::get_tocomid(as.data.frame(list(tonode = bct$tonode, comid=bct$comid, fromnode = bct$fromnode)), remove_coastal = FALSE, return_dendritic = FALSE )
# comid tocomid tonode fromnode
# 1 8567219 0 200061237 200061236
#
bct$comid
# 8567219
# notr this
nhdplusTools::navigate_nldi(bct$geometry)
# or this:
nhdplusTools::navigate_nldi(bct)
# both yield:
# Error in check_nldi_feature(nldi_feature) :
# Missing some required input for NLDI. Expected length 2 character vector or list with optional names: featureSource, featureID
Got this partially working due to help at nhdplusTools issue queue:
library(nhdplusTools)
#> USGS Support Package: https://owi.usgs.gov/R/packages.html#support
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
start_point <- st_sf(
id = 1,
geom = st_sfc(
st_point(
c(-78.652281, 38.071266)
),
crs = 4269
)
)
sf_use_s2(FALSE)
#> Spherical geometry (s2) switched off
domain <- st_buffer(st_as_sfc(st_bbox(start_point)), .1)
# grab some sample data and plot the domain
nhd <- plot_nhdplus(bbox = st_bbox(domain))
# Also plot the start point.
plot(st_geometry(st_transform(start_point, 3857)),
add = TRUE, col = "red", cex = 2)
start_point <- st_join(start_point, nhd$network_wtbd)
wb_out <- get_wb_outlet(lake_id = start_point$COMID,
network = nhd$flowline)
plot_nhdplus(outlets = list(wb_out$comid), streamorder = 2)
# fails with error:
# Error occured while plotting: Error in UseMethod("st_transform"): no applicable method for 'st_transform' applied to an object # of class "NULL"
# Warning messages:
# 1: Unknown or uninitialised column: `origin`.
# 2: In get_plot_data(outlets, bbox, streamord
# get an nhd feature with known comid
mc = nhdplusTools::get_nhdplus(comid='8566905')
# Get centroid of NHD catchment
mc_cent = st_centroid(mc$geometry)
# get lat and lon
mc_lon = mc_cent[[1]][[1]]
# [1] -78.66296
mc_lat = mc_cent[[1]][[2]]
Overview
Rscript.exe /c/usr/local/home/git/vahydro/R/modeling/json/nhdplus_nested.R
Outlet COMID (press ENTER to query by point):
hydr
variables to passtimeseries
variable inclusion and linkagehydr
routine already has timeseries variables imported, we can map variables already gathered to full path names, and then to IX values in thets
Dict for use inspecl()
hydr()
: callsload_nhd_simple()
afterhydr_get_ix()
sets up variables/Dictsload_nhd_simple()
loads an NHD+ file (currently hard-wired to Beaver Creek nhd_simple_8566737.json )Concepts
virtual FTABLE
can determine the approximate amount of water in the network at any point in time, and therefore estimate the head at any free flowing point in the network, given that head at any point in a network will be dependent on other pointsvirtual FTABLE
virtual FTABLE
groupCBP Architecture Support
Data Acquisition
plot_nhdplus()
catchment
: the actual catchmentsareaSqKM
: local drainage areaflowline
: the lines connecting catchments and waterbodiescomid
: relates it to a catchment featurefromNode
: this flowlines upstream most point (node) numbertoNode
: this flowlines downstream most point, shared as thefromNode
of the flowline that this flows intonetwork_wtb
: waterbodies on the connected flow line networkoff_network_wtb
: waterbodies not on the network