Package 'gwavr'

Title: Get Water Attributes Visually in R
Description: Provides methods to Get Water Attributes Visually in R ('gwavr'). This allows the user to point and click on areas within the United States and get back hydrological data, e.g. flowlines, catchments, basin boundaries, comids, etc.
Authors: Joshua Erickson [aut, cre]
Maintainer: Joshua Erickson <[email protected]>
License: MIT + file LICENSE
Version: 0.3.1
Built: 2024-10-25 06:19:15 UTC
Source: https://github.com/joshualerickson/gwavr

Help Index


Base Map

Description

A generic leaflet base map used in the shiny apps.

Usage

base_map()

Value

A leaflet map with provider layers: "Esri.WorldImagery", "CartoDB.Positron", "OpenStreetMap", "CartoDB.DarkMatter", "OpenTopoMap" "Hydrography"


Shiny Module Server for basin generation

Description

Shiny Module Server for basin generation

Usage

basinMod(input, output, session, values, dem, threshold = 1000, map, ...)

Arguments

input

Shiny server function input

output

Shiny server function output

session

Shiny server function session

values

A reactive Values list to pass

dem

A raster or terra object dem.

threshold

A threshold for stream initiation. 1000 (default).

map

a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

...

arguments to pass to wbt_* functions.

Value

server function for Shiny module


Shiny Module UI for basin generation

Description

A shiny Module to.

Usage

basinModUI(id, ...)

Arguments

id

character id for the the Shiny namespace

...

other arguments to leafletOutput()

Value

UI function for Shiny module


Convert GEOMETRYCOLLECTION to POLYGONS

Description

Convert GEOMETRYCOLLECTION to POLYGONS

Usage

convert_sf_geocollection(x)

Arguments

x

A sf object

Value

A converted sf object from GEOMETRYCOLLECTION to POLYGON or MULTIPOLYGON.


Retired USGS Sites

Description

A subset of data that has retired USGS sites and coordinates.

Usage

df_site_new

Format

df_site_new

A data frame with 14,966 rows and 4 columns:

SiteNumber

Site Number

SiteName

Site Name

location.coordinates1

Longitude coordinates

location.coordinates2

Latitude coordinates

...


Get Watershed Basin Interactively

Description

This function allows the user to delineate watershed basins interactively with a shiny app. It uses the elevatr package to acquire the Digital Elevation Model (DEM) or user inputted DEM and whitebox package to delineate the basin (see details).

Usage

get_basin_interactively(
  map = NULL,
  ns = "basin-ui",
  viewer = shiny::paneViewer(),
  title = "Delineate Basin",
  dem = NULL,
  threshold = 1000,
  ...
)

Arguments

map

a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "Delineate Basin".

dem

A 'SpatRaster' object dem. (optional)

threshold

A threshold for stream initiation. 1000 (default).

...

other arguments to leafletOutput() in module and/or wbt_* functions.

Details

This function will throw an error if you don't draw the bounding box (rectangle) first and you didn't include your own DEM. Once the user has drawn the bounding box (or added own DEM) then you can use the marker as a pour point location.

Steps

  1. Input a well-suited DEM zoom level and threshold. (skip if own DEM is inputted)

  2. Draw bounding box (rectangle or polygon) (skip if own DEM is inputted).

  3. Use marker to place pour point(s).

  4. If necessary, change 'Cell Threshold' to change drainage density.

  5. Repeat steps 1-4 if needed.

  6. When finished, press 'done' and basins will be saved as a list in local environment.

In addition, this function uses both whitebox::wbt_feature_preserving_smoothing() and whitebox::wbt_breach_depressions() prior to running the flow direction and flow accumulation (both d8) algorithms.

Value

A sf object that contains watershed polygons the user collected during shiny session.

Note

The marker will only work for the most current stream raster. You can have multiple areas but you need to make sure that you are on the most current raster when selecting basins or the app will crash. If you add your own DEM then you don't need to draw a bounding box.

Examples

if(interactive()){
basin_data <- get_basin_interactively()
}

Get NHDPlus Interactively

Description

This function allows the user go get NHDPlus realizations interactively with a shiny app.

Usage

get_nhdplus_interactively(
  ns = "hydro-ui",
  viewer = shiny::paneViewer(),
  title = "NHDPlus",
  ...
)

Arguments

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "NHDPlus".

...

other arguments to leafletOutput() in module.

Value

A list of sf objects that the user collected during shiny session.

Note

The picker list has several options right now: NHDPlus Catchments, NHDPlus Flowlines, NHDPlus Waterbodies, NHDPlus Outlet, HUC 2-12, NWIS Site.

Examples

if(interactive()){
nhdplus_data <- get_nhdplus_interactively()
}

Get Hydro Network-Linked Data Index (NLDI) Interactively

Description

This function uses the NLDI API to allow the user to visually select a location (point) to get numerous hydrologic realizations.

Usage

get_nldi_interactively()

Value

A list with sf objects.

Note

The picker list has three options right now: Total Basin, All Local Catchments and Only Local Catchment. Descriptions below:

  • Total Basin: This will return the upstream tributaries (UT), upstream main (UM), basin boundary and site data above the user point.

  • All Local Catchments: This will return the upstream tributaries (UT) and all the local NHDPLusV2 catchments above the user point. In addition, each catchment will contain the zonal stats associated with 'CAT' in NLDI.

  • Only Local Catchment: This will only return the catchment at the point and tributary. In addition, it will also include the zonal stat for that catchment.

Examples

if(interactive()){
nldi_data <- get_nldi_interactively()
}

Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14

Description

Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14

Usage

get_noaatlas(point, data_type = "depth", units = "english", series = "pds")

Arguments

point

An sf POINT object.

data_type

A character, e.g. 'depth' or 'intensity'.

units

A character, e.g. 'english' or 'metric'.

series

A character, e.g. 'pds' or 'ams'

Value

A tibble with quantiles, lower and upper bounds.


Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14 Interactively

Description

This function uses the National Oceanic and Atmospheric Administration (NOAA) Atlas 14 API to allow the user to visually select a location (point) to get numerous precipitation-frequency statistics.

Usage

get_noaatlas_interactively(
  map = NULL,
  ns = "noaatlas-ui",
  viewer = shiny::paneViewer(),
  title = "NOAA Atlas 14"
)

Arguments

map

A background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "NOAA Atlas 14".

Value

A data.frame.

Examples

if(interactive()){
noaatlas_data <- get_noaatlas_interactively()
}

Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14 Graphics

Description

Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14 Graphics

Usage

get_noaatlas_png(
  point,
  data_type = "depth",
  units = "english",
  series = "pds",
  dur,
  print = TRUE,
  destfile = NULL
)

Arguments

point

An sf POINT object.

data_type

A character, e.g. 'depth' or 'intensity'.

units

A character, e.g. 'english' or 'metric'.

series

A character, e.g. 'pds' or 'ams'

dur

A character, e.g. '10m', '4d', '24h', etc.

print

Logical, default printing of PNG in Rstudio Viewer

destfile

A character file path, default in NULL.

Value

A Portable Network Graphic printed to Rstudio Viewer.

Note

If print = FALSE, then the Graphic will be saved to tempfile or destination.


Get Stream Network Interactively

Description

This function allows the user to get stream networks and watersheds interactively with a shiny app. It uses the elevatr package to acquire the Digital Elevation Model (DEM) or user inputted DEM and whitebox package to delineate the stream network and watersheds (see details).

Usage

get_stream_network_interactively(
  map = NULL,
  ns = "streamnetwork-ui",
  viewer = shiny::paneViewer(),
  title = "Streamnetwork",
  dem = NULL,
  threshold = 1000,
  ...
)

Arguments

map

a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "Streamnetwork".

dem

A raster or terra object dem. (optional)

threshold

A threshold for stream initiation. 1000 (default).

...

other arguments to leafletOutput() in module and/or wbt_* functions.

Details

This function uses the package elevatr to download the DEM (unless you provide your own). Once the user has drawn the bounding box or inputed DEM and selected appropriate zoom (resolution) and threshold then the app will create basins and streams.

Steps

  1. Input a well-suited DEM zoom level and threshold. (skip if own DEM is inputted)

  2. Draw bounding box (rectangle or polygon) (skip if own DEM is inputted).

  3. Wait for layers to respond.

  4. Repeat steps 1-4 if needed.

  5. when finished, press 'done' and stream network and watersheds will be saved as a list in local environment with the associated flow accumulation and flow direction.

In addition, this function uses both whitebox::wbt_feature_preserving_smoothing() and whitebox::wbt_breach_depressions() prior to running the flow direction and flow accumulation (both d8) algorithms.

Value

A list of sf objects that the user collected during shiny session as well as flow accumulation and direction paths to tif. Each list will contain two sf objects: watersheds and streams. The streams object will also return these attributes: tribid, strahler, slope, length, mainstem, FID, STRM_VAL.

Note

If you add your own DEM then you don't need to draw a bounding box.

Examples

if(interactive()){
streamnetwork <- get_stream_network_interactively()
}

Get United States Geologic Survey (USGS) Daily Flow Values Interactively

Description

This function allows the user to select United States Geologic Survey (USGS) stations and get back daily flow values based on station selected. It uses the USGS Water Services to get the values as well as the USGS Sites.

Usage

get_usgs_dv_interactively(
  ns = "usgsdv-ui",
  viewer = shiny::paneViewer(),
  title = "Get USGS Daily Flow Values",
  ...
)

Arguments

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "Get USGS Instantaneous Flow Values".

...

other arguments to leafletOutput() in module.

Details

Steps

  1. Select the sites you want to retrieve.

  2. When finished, press 'done' and sites daily flow values will be saved to a data.frame in local environment.

Value

A data.frame that contains flow values based on the station(s) selected during shiny session.

Note

You can select multiple stations. The information from the hover details is not included in the data.frame that is returned, e.g. rate of change, percentile description.

Examples

if(interactive()){
dv_usgs <- get_usgs_dv_interactively()
}

Get United States Geologic Survey (USGS) Instantaneous Flow Values Interactively

Description

This function allows the user to select United States Geologic Survey (USGS) stations and get back instantaneous flow values based on control ⁠number of days from now⁠. It uses the USGS Water Services to get the values as well as the USGS Dashboard to get current conditions (circle markers on map).

Usage

get_usgs_iv_interactively(
  ns = "usgsiv-ui",
  viewer = shiny::paneViewer(),
  title = "Get USGS Instantaneous Flow Values",
  ...
)

Arguments

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "Get USGS Instantaneous Flow Values".

...

other arguments to leafletOutput() in module.

Details

Steps

  1. Select the sites you want to retrieve.

  2. Make sure you have the right days.

  3. When finished, press 'done' and sites instantaneous flow values will be saved to a data.frame in local environment.

Value

A data.frame that contains flow values based on the station(s) selected during shiny session.

Note

You can select multiple stations but the ⁠number of days from now⁠ control will take the final number when you select the done button. The information from the hover details is not included in the data.frame that is returned, e.g. rate of change, percentile description.

Examples

if(interactive()){
iv_usgs <- get_usgs_iv_interactively()
}

Shiny Module Server for nhdplus

Description

Shiny Module Server for nhdplus

Usage

nhdplusMod(input, output, session, values)

Arguments

input

Shiny server function input

output

Shiny server function output

session

Shiny server function session

values

A reactive Values list to pass

Value

server function for Shiny module


Shiny Module UI for nhdplus

Description

A shiny Module to.

Usage

nhdplusModUI(id, ...)

Arguments

id

character id for the the Shiny namespace

...

other arguments to leafletOutput()

Value

UI function for Shiny module


Shiny Module Server for National Oceanic and Atmospheric Administration (NOAA) Atlas 14

Description

Shiny Module Server for National Oceanic and Atmospheric Administration (NOAA) Atlas 14

Usage

noaatlasMod(input, output, session, values, map)

Arguments

input

Shiny server function input

output

Shiny server function output

session

Shiny server function session

values

A reactive Values list to pass

map

A background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

Value

server function for Shiny module


Shiny Module UI for National Oceanic and Atmospheric Administration (NOAA) Atlas 14

Description

A shiny Module to get numerous precipitation-frequency statistics.

Usage

noaatlasModUI(id, ...)

Arguments

id

character id for the the Shiny namespace

...

other arguments to leafletOutput()

Value

UI function for Shiny module


Rename Geometry Column

Description

Rename Geometry Column

Usage

rename_geometry(g, name)

Arguments

g

A sf object

name

character.

Value

A sf object with a renamed geometry column.

Note

This function was grabbed from stack overflow from the legend spacedman.


Shiny Module Server for stream networks

Description

Shiny Module Server for stream networks

Usage

streamnetworkMod(
  input,
  output,
  session,
  values,
  dem,
  threshold = 1000,
  map,
  ...
)

Arguments

input

Shiny server function input

output

Shiny server function output

session

Shiny server function session

values

A reactive Values list to pass

dem

A raster or terra object dem. (optional)

threshold

A threshold for stream initiation. 1000 (default).

map

a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

...

arguments to pass to wbt_* functions.

Value

server function for Shiny module


Shiny Module UI for stream network generation

Description

A shiny Module to.

Usage

streamnetworkModUI(id, ...)

Arguments

id

character id for the the Shiny namespace

...

other arguments to leafletOutput()

Value

UI function for Shiny module


Shiny Module Server for United States Geologic Survey (USGS) daily values

Description

Shiny Module Server for United States Geologic Survey (USGS) daily values

Usage

usgsdvMod(input, output, session, values)

Arguments

input

Shiny server function input

output

Shiny server function output

session

Shiny server function session

values

A reactive Values list to pass

Value

server function for Shiny module


Shiny Module UI for United States Geologic Survey (USGS) daily values

Description

A shiny Module to.

Usage

usgsdvModUI(id, ...)

Arguments

id

character id for the the Shiny namespace

...

other arguments to leafletOutput()

Value

UI function for Shiny module


Shiny Module Server for United States Geologic Survey (USGS) instantaneous values

Description

Shiny Module Server for United States Geologic Survey (USGS) instantaneous values

Usage

usgsinstMod(input, output, session, values)

Arguments

input

Shiny server function input

output

Shiny server function output

session

Shiny server function session

values

A reactive Values list to pass

Value

server function for Shiny module


Shiny Module UI for United States Geologic Survey (USGS) instantaneous values

Description

A shiny Module to.

Usage

usgsinstModUI(id, ...)

Arguments

id

character id for the the Shiny namespace

...

other arguments to leafletOutput()

Value

UI function for Shiny module