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 |
A generic leaflet base map used in the shiny apps.
base_map()
base_map()
A leaflet map with provider layers: "Esri.WorldImagery", "CartoDB.Positron", "OpenStreetMap", "CartoDB.DarkMatter", "OpenTopoMap" "Hydrography"
Shiny Module Server for basin generation
basinMod(input, output, session, values, dem, threshold = 1000, map, ...)
basinMod(input, output, session, values, dem, threshold = 1000, map, ...)
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. |
server function for Shiny module
A shiny Module to.
basinModUI(id, ...)
basinModUI(id, ...)
id |
|
... |
other arguments to |
UI function for Shiny module
Convert GEOMETRYCOLLECTION to POLYGONS
convert_sf_geocollection(x)
convert_sf_geocollection(x)
x |
A sf object |
A converted sf object from GEOMETRYCOLLECTION to POLYGON or MULTIPOLYGON.
A subset of data that has retired USGS sites and coordinates.
df_site_new
df_site_new
df_site_new
A data frame with 14,966 rows and 4 columns:
Site Number
Site Name
Longitude coordinates
Latitude coordinates
...
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).
get_basin_interactively( map = NULL, ns = "basin-ui", viewer = shiny::paneViewer(), title = "Delineate Basin", dem = NULL, threshold = 1000, ... )
get_basin_interactively( map = NULL, ns = "basin-ui", viewer = shiny::paneViewer(), title = "Delineate Basin", dem = NULL, threshold = 1000, ... )
map |
a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided. |
ns |
|
viewer |
|
title |
|
dem |
A 'SpatRaster' object dem. (optional) |
threshold |
A threshold for stream initiation. 1000 (default). |
... |
other arguments to |
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
Input a well-suited DEM zoom level and threshold. (skip if own DEM is inputted)
Draw bounding box (rectangle or polygon) (skip if own DEM is inputted).
Use marker to place pour point(s).
If necessary, change 'Cell Threshold' to change drainage density.
Repeat steps 1-4 if needed.
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.
A sf object that contains watershed polygons the user collected during shiny session.
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.
if(interactive()){ basin_data <- get_basin_interactively() }
if(interactive()){ basin_data <- get_basin_interactively() }
This function allows the user go get NHDPlus realizations interactively with a shiny app.
get_nhdplus_interactively( ns = "hydro-ui", viewer = shiny::paneViewer(), title = "NHDPlus", ... )
get_nhdplus_interactively( ns = "hydro-ui", viewer = shiny::paneViewer(), title = "NHDPlus", ... )
ns |
|
viewer |
|
title |
|
... |
other arguments to |
A list of sf objects that the user collected during shiny session.
The picker list has several options right now: NHDPlus Catchments, NHDPlus Flowlines, NHDPlus Waterbodies, NHDPlus Outlet, HUC 2-12, NWIS Site.
if(interactive()){ nhdplus_data <- get_nhdplus_interactively() }
if(interactive()){ nhdplus_data <- get_nhdplus_interactively() }
This function uses the NLDI API to allow the user to visually select a location (point) to get numerous hydrologic realizations.
get_nldi_interactively()
get_nldi_interactively()
A list with sf objects.
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.
if(interactive()){ nldi_data <- get_nldi_interactively() }
if(interactive()){ nldi_data <- get_nldi_interactively() }
Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14
get_noaatlas(point, data_type = "depth", units = "english", series = "pds")
get_noaatlas(point, data_type = "depth", units = "english", series = "pds")
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' |
A tibble with quantiles, lower and upper bounds.
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.
get_noaatlas_interactively( map = NULL, ns = "noaatlas-ui", viewer = shiny::paneViewer(), title = "NOAA Atlas 14" )
get_noaatlas_interactively( map = NULL, ns = "noaatlas-ui", viewer = shiny::paneViewer(), title = "NOAA Atlas 14" )
map |
A background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided. |
ns |
|
viewer |
|
title |
|
A data.frame.
if(interactive()){ noaatlas_data <- get_noaatlas_interactively() }
if(interactive()){ noaatlas_data <- get_noaatlas_interactively() }
Get National Oceanic and Atmospheric Administration (NOAA) Atlas 14 Graphics
get_noaatlas_png( point, data_type = "depth", units = "english", series = "pds", dur, print = TRUE, destfile = NULL )
get_noaatlas_png( point, data_type = "depth", units = "english", series = "pds", dur, print = TRUE, destfile = NULL )
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. |
A Portable Network Graphic printed to Rstudio Viewer.
If print = FALSE
, then the Graphic will be saved to tempfile or destination.
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).
get_stream_network_interactively( map = NULL, ns = "streamnetwork-ui", viewer = shiny::paneViewer(), title = "Streamnetwork", dem = NULL, threshold = 1000, ... )
get_stream_network_interactively( map = NULL, ns = "streamnetwork-ui", viewer = shiny::paneViewer(), title = "Streamnetwork", dem = NULL, threshold = 1000, ... )
map |
a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided. |
ns |
|
viewer |
|
title |
|
dem |
A raster or terra object dem. (optional) |
threshold |
A threshold for stream initiation. 1000 (default). |
... |
other arguments to |
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
Input a well-suited DEM zoom level and threshold. (skip if own DEM is inputted)
Draw bounding box (rectangle or polygon) (skip if own DEM is inputted).
Wait for layers to respond.
Repeat steps 1-4 if needed.
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.
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
.
If you add your own DEM then you don't need to draw a bounding box.
if(interactive()){ streamnetwork <- get_stream_network_interactively() }
if(interactive()){ streamnetwork <- get_stream_network_interactively() }
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.
get_usgs_dv_interactively( ns = "usgsdv-ui", viewer = shiny::paneViewer(), title = "Get USGS Daily Flow Values", ... )
get_usgs_dv_interactively( ns = "usgsdv-ui", viewer = shiny::paneViewer(), title = "Get USGS Daily Flow Values", ... )
ns |
|
viewer |
|
title |
|
... |
other arguments to |
Steps
Select the sites you want to retrieve.
When finished, press 'done' and sites daily flow values will be saved to a data.frame in local environment.
A data.frame that contains flow values based on the station(s) selected during shiny session.
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.
if(interactive()){ dv_usgs <- get_usgs_dv_interactively() }
if(interactive()){ dv_usgs <- get_usgs_dv_interactively() }
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).
get_usgs_iv_interactively( ns = "usgsiv-ui", viewer = shiny::paneViewer(), title = "Get USGS Instantaneous Flow Values", ... )
get_usgs_iv_interactively( ns = "usgsiv-ui", viewer = shiny::paneViewer(), title = "Get USGS Instantaneous Flow Values", ... )
ns |
|
viewer |
|
title |
|
... |
other arguments to |
Steps
Select the sites you want to retrieve.
Make sure you have the right days.
When finished, press 'done' and sites instantaneous flow values will be saved to a data.frame in local environment.
A data.frame that contains flow values based on the station(s) selected during shiny session.
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.
if(interactive()){ iv_usgs <- get_usgs_iv_interactively() }
if(interactive()){ iv_usgs <- get_usgs_iv_interactively() }
Shiny Module Server for nhdplus
nhdplusMod(input, output, session, values)
nhdplusMod(input, output, session, values)
input |
Shiny server function input |
output |
Shiny server function output |
session |
Shiny server function session |
values |
A reactive Values list to pass |
server function for Shiny module
A shiny Module to.
nhdplusModUI(id, ...)
nhdplusModUI(id, ...)
id |
|
... |
other arguments to |
UI function for Shiny module
Shiny Module Server for National Oceanic and Atmospheric Administration (NOAA) Atlas 14
noaatlasMod(input, output, session, values, map)
noaatlasMod(input, output, session, values, map)
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. |
server function for Shiny module
A shiny Module to get numerous precipitation-frequency statistics.
noaatlasModUI(id, ...)
noaatlasModUI(id, ...)
id |
|
... |
other arguments to |
UI function for Shiny module
Rename Geometry Column
rename_geometry(g, name)
rename_geometry(g, name)
g |
A sf object |
name |
character. |
A sf object with a renamed geometry column.
This function was grabbed from stack overflow from the legend spacedman.
Shiny Module Server for stream networks
streamnetworkMod( input, output, session, values, dem, threshold = 1000, map, ... )
streamnetworkMod( input, output, session, values, dem, threshold = 1000, map, ... )
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. |
server function for Shiny module
A shiny Module to.
streamnetworkModUI(id, ...)
streamnetworkModUI(id, ...)
id |
|
... |
other arguments to |
UI function for Shiny module
Shiny Module Server for United States Geologic Survey (USGS) daily values
usgsdvMod(input, output, session, values)
usgsdvMod(input, output, session, values)
input |
Shiny server function input |
output |
Shiny server function output |
session |
Shiny server function session |
values |
A reactive Values list to pass |
server function for Shiny module
A shiny Module to.
usgsdvModUI(id, ...)
usgsdvModUI(id, ...)
id |
|
... |
other arguments to |
UI function for Shiny module
Shiny Module Server for United States Geologic Survey (USGS) instantaneous values
usgsinstMod(input, output, session, values)
usgsinstMod(input, output, session, values)
input |
Shiny server function input |
output |
Shiny server function output |
session |
Shiny server function session |
values |
A reactive Values list to pass |
server function for Shiny module
A shiny Module to.
usgsinstModUI(id, ...)
usgsinstModUI(id, ...)
id |
|
... |
other arguments to |
UI function for Shiny module