knitr::opts_chunk$set(  collapse = TRUE,
  comment = "#>",
  out.width = "100%",
  warning = FALSE, message = FALSE)
library(hydrofabric)

NextGen

Once we have a network aggregated to a scale matching the desired hydrologic processes we need to turn it into something NextGen can use (modeling task)

knitr::include_graphics('../man/figures/roadmap2.png')

Divergent Topology

NextGen operates on a [flowpath --> nexus] vs [flowpath --> flowpath] topology

This is due to the HY Features conceptual catchment that has 1 inflow draining to 1 outflow.

And example of this can be seen below:

knitr::include_graphics(c('../man/figures/topology.png', '../man/figures/topology2.png'))

Character based indentification

NextGen requires integer based identification, like described in the data model, prefixed with a character string defining what the feature is

Right now, the following prefixs are used to distinguish between types of model features.

| Parameter | Purpose | Elected Value | | ------------- |:-------------:| -----:| | nexus_prefix | the maximum length flowpath desired in the output. | "nex-" | | terminal_nexus_prefix | the minimum length of inter-confluence flowpath desired in the output. | "tnx-" | | coastal_nexus_prefix | the minimum length of between-confluence flowpaths. | "cnx-" | | internal_nexus_prefix | the maximum length flowpath desired in the output. | "inx-" | | catchment_prefix | the minimum length of inter-confluence flowpath desired in the output. | "cat-" | | waterbody_prefix | the minimum length of between-confluence flowpaths. | "wb-" |

The following function (1) identifies nexus locations, (2) moves them when needed and (3) applies the above schema to the features.

ngen <- apply_nexus_topology(gpkg = "../inst/extdata//aggregate.gpkg", 
                             export_gpkg = '../inst/extdata//nextgen.gpkg')

We can see the results of this by opening the hydrofabric and adding it to a map!

mapview::mapview(read_hydrofabric(ngen)) + read_sf(ngen, "nexus")

Extending NWM attributes

The core utilities provide a series of flowpath, divide, and nexuses.

sf::st_layers(ngen)

However, other information is needed to run some/all NextGen formulations. These include the following:

Lake Attributes

Flowpath Attributes

For example, if a 75m flowline has a roughness of 0.05 and a 25m flowline with a roughness of 0.2

(n = (.75 * .05) + (.25 * .2))

Flowpaths attributes and lake parameters can be added by pointing to a set of NWM domain files like those found here

add_flowpath_attributes(ngen, source = "/Users/mjohnson/hydrofabric")
read_sf(ngen, "flowpath_attributes")

Themeing

As an option, QGIS QML theming files can be added to a gpkg. Some default themeing files come with hydrofabric and can be specified/added with the append_styles utility on the desired layer_names

append_style(ngen,layer_names = c("nexus", "hydrolocations", "flowpaths", "divides", "lakes"))

In QGIS, double clicking the gpkg file will allow you to select which layers to load.

knitr::include_graphics("../man/figures/hydrofabric.png")


NOAA-OWP/hydrofabric documentation built on Dec. 7, 2024, 11:24 a.m.