Title: Interface to the Lake Multi-Scaled Geospatial and Temporal Database
Version: 2.0.3
URL: https://github.com/cont-limno/LAGOSNE, https://cont-limno.github.io/LAGOSNE/
BugReports: https://github.com/cont-limno/LAGOSNE/issues
Description: Client for programmatic access to the Lake Multi-scaled Geospatial and Temporal database https://lagoslakes.org, with functions for accessing lake water quality and ecological context data for the US.
Depends: R (≥ 3.5.0)
Imports: dplyr (≥ 0.7.0), rappdirs (≥ 0.3.1), lazyeval (≥ 0.2), purrr (≥ 0.2.2.2), magrittr (≥ 1.5), sf, curl (≥ 2.7.0), stringr (≥ 1.2.0), tibble, tidyr, memoise, rlang, progress, qs, httr
Suggests: testthat, knitr, rmarkdown, devtools, R.rsp, printr, ggplot2
License: GPL-2 | GPL-3 [expanded from: GPL]
Encoding: UTF-8
RoxygenNote: 7.2.3
VignetteBuilder: R.rsp, knitr
Language: en-US
NeedsCompilation: no
Packaged: 2023-06-16 20:11:19 UTC; 358572
Author: Jemma Stachelek ORCID iD [aut, cre], Samantha Oliver ORCID iD [aut], Farzan Masrour [aut]
Maintainer: Jemma Stachelek <jemma.stachelek@gmail.com>
Repository: CRAN
Date/Publication: 2023-06-16 22:40:03 UTC

R interface to the LAGOSNE lakes database

Description

Interface to the LAGOSNE lakes database

Author(s)

stachel2@msu.edu


Climate, Hydrology, Atmospheric, and Geologic (CHAG) Datasets

Description

Datasets containing information on climate, hydrology, atmospheric deposition, and surficial geology characteristics calculated at hu12, hu8, hu4, edu, county and state spatial classifications (see ?scales).

Format

Data frames with all or a subset of the following variables. Number of observations is equal to the number of zones in each spatial scale (see Details below). Wildcard options include a subset of the LAGOSNE spatial scales (* = hu12, hu8, hu4, edu, county, state), years of measurement (** = 1985, 1990, 1995, 2000, 2005, 2010), and summary statistic or units (*** = min, max, mean, std for atmospheric deposition and hydrology; *** = ha, pct for surficial geology)

Details

Original data sources and layers from which each metric was derived can be found in additional file 5 of Soranno et al. (2015). Briefly, climate data came from the PRISM climate group, hydrology metrics were derived from United States Geologic Survey (USGS) data, atmospheric deposition was from the National Atmospheric Deposition program, and surficial geology were derived from layers USGS data.

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101


LAGOSNE Spatial Classifications Metadata

Description

Data frames containing metadata for each spatial classification at which ecological context data are derived in LAGOSNE. The spatial classifications include 100m buffers (buffer100m), 500m buffers (buffer500m), interlake watersheds (iws), hydrologic units (hu12, hu8, hu4), ecological drainage units (edu), counties (county), and states (state). Each abbreviation is the name of the data frame, with all or a subset of the following variables. For more information about derivation of each spatial classification, see Details below or Additional file 7 from doi:10.1186/s13742-015-0067-4.

Format

Data frames with all or a subset of the following variables. Number of observations is equal to the number of zones in each spatial classification (see Details below).

Details

The nine LAGOSNE spatial classifications were used to summarize the ecological context of each lake. Ecological context themes include land use/land cover (LULC), connectivity (CONN), and climate, hydrology, atmospheric deposition, and groundwater (CHAG). Not all themes were derived at all classifications due to data availability. Briefly:

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101

See Also

conn lakes.geo chag lulc


Connectivity Datasets

Description

Datasets containing lake, stream, and wetland abundance and connectivity metrics calculated at the 500m buffer (buffer500m.conn), HUC12 (hu12.conn), HUC8 (hu8.conn), HUC4 (hu4.conn), EDU (edu.conn), county (county.conn) and state (state.conn) classifications.

Format

Data frames with all or a subset of the following variables. Number of observations is equal to the number of zones in each spatial classification (see ?classifications). Wildcard options include a subset of the LAGOSNE spatial classifications (* = buffer500m, iws, hu12, hu8, hu4, edu, county, state) and additional wildcards described below.

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101Gigascience 6:12

See Also

lakes.geo


Convert a LAGOSNE flat file into a spatial object

Description

This function turns a data.frame into a spatial object using a reasonable default projection.

Usage

coordinatize(dt, latname = "nhd_lat", longname = "nhd_long", crs = 4326)

Arguments

dt

data.frame

latname

character name of latitude column; default is "nhd_lat"

longname

character name of longitude column; default is "nhd_long"

crs

numeric epsg code; default is 4326 WGS84-lat-long

Examples

## Not run: 
dt <- lagosne_load("1.087.3")
res <- coordinatize(dt$locus)

library(maps)
map("state", xlim = c(-97.90363, -66.99892), ylim = c(34.61761, 49.41941))
plot(res$geometry, add = TRUE, pch = 19, cex = 0.05)

## End(Not run)

Convert table names for display

Description

Convert table names for display

Usage

display_names(nms_raw)

Arguments

nms_raw

character vector of column names

Examples

## Not run: 
lg <- lagosne_load("1.087.3")
cbind(names(lg$iws), display_names(names(lg$iws)))
cbind(names(lg$county.chag), display_names(names(lg$county.chag)))
cbind(names(lg$county.conn), display_names(names(lg$county.conn)))
cbind(names(lg$county.lulc), display_names(names(lg$county.lulc)))
cbind(names(lg$hu4), display_names(names(lg$hu4)))
cbind(names(lg$locus), display_names(names(lg$locus)))
cbind(names(lg$epi_nutr), display_names(names(lg$epi_nutr)))
cbind(names(lg$lakes_limno), display_names(names(lg$lakes_limno)))
cbind(names(lg$lakes.geo), display_names(names(lg$lakes.geo)))

## End(Not run)

Epilimnion Water Quality Data

Description

A dataset containing physical and chemical observations in the epilimnion (surface waters). Each row is a sampling event, and lakes can have multiple sampling events.

Format

A data frame with observations of 93 variables:

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101


Summarize all LAGOSNE flat files

Description

Generate table summary statistics for all LAGOSNE data frames.

Usage

info_table(lg)

Arguments

lg

list output of lagosne_load

Author(s)

Masrour Farzan

Examples

## Not run: 
lg <- lagosne_load("1.087.3")
LAGOSNE:::info_table(lg)

## End(Not run)

Get LAGOSNE snapshot from Collins et al. 2017

Description

Get LAGOSNE snapshot from Collins et al. 2017

Usage

lagos_get_collins_2017(dest_folder, overwrite = FALSE)

Arguments

dest_folder

file.path not implemented yet

overwrite

logical overwrite existing data?

References

Collins S., S. Oliver, J. Lapierre, E. Stanley, J. Jones, T. Wagner, P. Soranno. 2016. LAGOS - Lake nitrogen, phosphorus, stoichiometry, and geospatial data for a 17-state region of the U.S.. Environmental Data Initiative. doi:10.6073/pasta/3abb4a56e76a52a12a366a338fc07dd8.

Examples

## Not run: 
lagos_get_collins_2017()

## End(Not run)

Get depth data from Oliver et al. 2015

Description

Get depth data from Oliver et al. 2015

Usage

lagos_get_oliver_2015(dest_folder, overwrite = FALSE)

Arguments

dest_folder

file.path not implemented yet

overwrite

logical overwrite existing data?

References

Oliver SK, Soranno PA, Fergus EC, Wagner T, Webster KE, Scott C, Winslow LA, Downing JA, Stanley EH. 2015. LAGOS - Predicted and observed maximum depth values for lakes in a 17-state region of the U.S. Long Term Ecological Research Network. doi:10.6073/pasta/f00a245fd9461529b8cd9d992d7e3a2f

Examples

## Not run: 
lagos_get_oliver_2015()

## End(Not run)

Ingest LAGOSNE flat files

Description

Ingest LAGOSNE data from component flat files

Usage

lagos_ingest(version, limno_folder = NA, geo_folder = NA, locus_folder = NA)

Arguments

version

character LAGOSNE database version string

limno_folder

file.path to limno export folder. optional.

geo_folder

file.path to geo export folder. optional.

locus_folder

file.path to locus export folder. optional.

Examples

## Not run: 
lagos_ingest("1.087.3",
 limno_folder = "~/Downloads/LAGOS-NE-LIMNO-EXPORT",
 geo_folder   = "~/Downloads/LAGOS-NE-GEO-EXPORT",
 locus_folder = "~/Downloads/LAGOS-NE-LOCUS-EXPORT")

## End(Not run)

Load LAGOSNE snapshot from Collins et al. 2017.

Description

Load LAGOSNE snapshot from Collins et al. 2017.

Usage

lagos_load_collins_2017(fpath = NA)

Arguments

fpath

file.path optionally specify custom location of csv data file

References

Collins S., S. Oliver, J. Lapierre, E. Stanley, J. Jones, T. Wagner, P. Soranno. 2016. LAGOS - Lake nitrogen, phosphorus, stoichiometry, and geospatial data for a 17-state region of the U.S.. Environmental Data Initiative. doi:10.6073/pasta/3abb4a56e76a52a12a366a338fc07dd8.

Examples

## Not run: 
lg <- lagos_load_collins_2017()

## End(Not run)

Load depth data from Oliver et al. 2015.

Description

Load depth data from Oliver et al. 2015.

Usage

lagos_load_oliver_2015(fpath = NA)

Arguments

fpath

file.path optionally specify custom location of csv data file

Format

A data frame with 50607 observations of 8 variables:

References

Oliver SK, Soranno PA, Fergus EC, Wagner T, Webster KE, Scott C, Winslow LA, Downing JA, Stanley EH. 2015. LAGOS - Predicted and observed maximum depth values for lakes in a 17-state region of the U.S. Long Term Ecological Research Network. doi:10.6073/pasta/f00a245fd9461529b8cd9d992d7e3a2f

Examples

## Not run: 
lagos_load_oliver_2015()

## End(Not run)

Return the cross-platform data path designated for LAGOSNE.

Description

Return the cross-platform data path designated for LAGOSNE.

Usage

lagos_path()

LAGOSNE sources

Description

A dataset identifying the sources of limnological data in LAGOSNE.

Format

A data frame with observations of 19 variables:

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101


Lake Geospatial Metadata

Description

A dataset containing geospatial identifiers, upstream lake connectivity, and wetland connectivity of all lakes in LAGOSNE >1 hectare.

Format

A data frame with 141271 observations and 31 variables:

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101


Compile LAGOSNE data

Description

Compile LAGOSNE data from component flat files. This function should rarely be called directly outside of manual updating of source data.

Usage

lagosne_compile(
  version,
  limno_folder = NA,
  geo_folder = NA,
  locus_folder = NA,
  dest_folder = NA
)

Arguments

version

character LAGOSNE database version string

limno_folder

file.path to limno export folder

geo_folder

file.path to geo export folder

locus_folder

file.path to locus export folder

dest_folder

file.path optional will default to the location returned by user_data_dir

Examples

## Not run: 
lagosne_compile("1.087.3",
 limno_folder = "~/Downloads/LAGOS-NE-LIMNO-EXPORT",
 geo_folder   = "~/Downloads/LAGOS-NE-GEO-EXPORT",
 locus_folder = "~/Downloads/LAGOS-NE-LOCUS-EXPORT",
 dest_folder = lagos_path())

## End(Not run)


Retrieve LAGOSNE flat files

Description

Retrieve LAGOSNE flat files from EDI.

Usage

lagosne_get(
  version = lagosne_version(),
  overwrite = FALSE,
  dest_folder = tempdir()
)

Arguments

version

character LAGOSNE database version string

overwrite

logical overwrite existing data for the specified version

dest_folder

file.path to save data. Default to a temporary folder. Recommended to set to LAGOSNE:::lagos_path() so that data persists between R sessions.

Examples

## Not run: 
# default to latest version
lagosne_get(dest_folder = LAGOSNE:::lagos_path())

# get previous version(s)
# - recommended to install corresponding package version
# - See 'Legacy Versions' section of the README for instructions

## End(Not run)

Load LAGOSNE data

Description

Load LAGOSNE data from local system files

Usage

lagosne_load(version = NULL, fpath = NA)

Arguments

version

character LAGOSNE database version string. Defaults to lagosne_version

fpath

file.path optionally specify custom location of LAGOSNE rds file

Examples

## Not run: 
dt  <- lagosne_load("1.087.3")

## End(Not run)

Select and filter LAGOSNE data

Description

Select and filter LAGOSNE data with keyword helpers.

Usage

lagosne_select(
  table = NULL,
  vars = NULL,
  categories = NULL,
  dt = lagosne_load(lagosne_version())
)

Arguments

table

character name of a dt table

vars

character vector of specific column names to select from table

categories

what type of variables should be kept. Note not all scale-category options are available. Variable categories include:

  • "waterquality" - includes all in-situ chemistry, chlorophyll, and water clarity measurements from the epi_nutr table.

  • "deposition" - all atmospheric deposition variables from the .chag tables

  • "hydrology" - baseflow, groundwater, runoff, and overland flow variables from the .chag tables

  • "climate" - 30-year normal precipitation and temperature variables from the .chag tables

  • "geology" - all surficial geology variables from the .chag tables

  • "topography" - Terrain Roughness Index and slope variables from the .lulc tables

  • "lulc1992" - all 1992 land use/land cover variables from the .lulc tables

  • "lulc2001" - all 2001 land use/land cover variables from the .lulc tables

  • "lulc2006" - all 2006 land use/land cover variables from the .lulc tables

  • "lulc2011" - all 2011 land use/land cover variables from the .lulc tables

  • "lakes" - all lake connectivity metrics from the .conn tables

  • "wetlands" - all wetland connectivity metrics from the .conn tables

  • "streams" - all stream/river connectivity metrics from the .conn tables

dt

data.frame of local copy of LAGOSNE data. Can be loaded with lagosne_load and will use version as specified in lagosne_version.

Examples

## Not run: 
dt <- lagosne_load("1.087.3")

# specific variables
head(lagosne_select(table = "epi_nutr", vars = c("tp", "tn")))
head(lagosne_select(table = "iws.lulc", vars = c("iws_nlcd2011_pct_95")))

# categories
head(lagosne_select(table = "epi_nutr", categories = "waterquality"))
head(lagosne_select(table = "county.chag", categories = "hydrology"))
head(lagosne_select(table = "hu4.chag", categories = "deposition"))

# mix of specific variables and categories
head(lagosne_select(table = "epi_nutr", vars = "lagoslakeid", categories = c("waterquality")))


## End(Not run)

Latest LAGOSNE version

Description

Latest LAGOSNE version

Usage

lagosne_version()

Examples

lagosne_version()

Get a summary of lake attribute information

Description

Return lake attribute information from its name and state or its lagoslakeid.

Usage

lake_info(lagoslakeid = NA, name = NA, state = NA, dt = lagosne_load(), ...)

Arguments

lagoslakeid

numeric lake id

name

character lake name not caps sensitive

state

character state name not caps sensitive

dt

list of data.frames. output of lagosne_load.

...

arguments passed to agrepl to fuzzy match lake name

Examples

## Not run: 
lake_info(lagoslakeid = 4314)
lake_info(lagoslakeid = 7441)
lake_info(lagoslakeid = 244)
lake_info(lagoslakeid = 4686)
lake_info(lagoslakeid = 8016)
lake_info(lagoslakeid = c(21864, 2317))
lake_info(lagoslakeid = c(1441))
lake_info(lagoslakeid = c(125428, 1441))
lake_info(lagoslakeid = c(4686, 8016))

# fuzzy matching to lake name
lake_info(name = "Duck Lake", state = "Michigan")
# exact matching to lake name
lake_info(name = "Duck Lake", state = "Michigan",
          max.distance = list(all = 0))

lake_info(name = "Sunapee Lake", state = "New Hampshire")
lake_info(name = c("Sunapee Lake", "Oneida Lake"),
              state = c("New Hampshire", "New York"))

## End(Not run)

Metadata for Lakes with Water Quality

Description

A dataset containing depth and names for lakes included in the limno module.

Format

A data frame with observations of 8 variables:

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101Gigascience 6:12

See Also

lakes.geo


The spatial extent of LAGOSNE data

Description

A dataset containing the spatial extent of LAGOSNE data.

Format

A single sf polygon


Load LAGOSNE data from disk

Description

A wrapper for read.table with a default set of parameters.

Usage

load_lagos_txt(file_name, sep = "\t", ...)

Arguments

file_name

character

sep

character separator (tab or comma separated values)

...

Options passed on to read.table

Value

data.frame


Metadata for all lakes > 1ha

Description

A dataset containing identifying information for all lakes > 1ha. This includes lake name, lake size (area and perimeter), location (lat/long), elevation, and codes identifying zones in which the lake is located.

Format

A data frame with 141265 observations of 17 variables:

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101

See Also

lakes.geo


Land Use Land Cover (LULC) Data Frames

Description

Datasets containing information on the land use and land cover (LULC) characteristics calculated at all LAGOSNE spatial classifications (see ?scales) from the National Land Cover Dataset (NLCD).

Format

Data frames with all or a subset of the following variables. Number of observations is equal to the number of zones in each spatial scale (see Details below). Wildcard options include the 9 LAGOSNE spatial scales (* = buffer100m, buffer500m, iws, hu12, hu8, hu4, edu, county, state), year of measurement (** = 1992, 2001, 2006, 2011), and unit of measurement in hectares or percent of zone area (*** = ha, pct unless noted otherwise). Each variable is available at each scale, year, and unit unless otherwise noted.

Details

Original data sources and layers from which each metric was derived can be found in additional file 5 of Soranno et al. (2015).

References

Soranno et al. (2017) doi:10.1093/gigascience/gix101

See Also

lakes.geo


Query column keywords

Description

Return a vector of column names, given a table name and keyword string.

Usage

query_column_keywords(dt, table_name, keyword_string)

Arguments

dt

data.frame

table_name

character

keyword_string

character

Examples

## Not run: 
dt <- lagosne_load("1.087.3")
query_column_keywords(dt, "hu12.chag", "hydrology")

## End(Not run)

Query column names

Description

Return a vector of column names, given a table name and grep query string.

Usage

query_column_names(dt, table_name, grep_string)

Arguments

dt

data.frame

table_name

character

grep_string

character

Examples

## Not run: 
dt <- lagosne_load("1.087.3")
query_column_names(dt, "hu4.chag", "_dep_")
query_column_names(dt, "county.chag", "baseflowindex")

## End(Not run)

Query LAGOSNE names

Description

Return a vector of table names whose associated tables have columns that grep to query.

Usage

query_lagos_names(grep_string, scale = NA, dt = lagosne_load())

Arguments

grep_string

character search string to grep to table column names

scale

character filter results by one of:

  • county

  • edu

  • hu4

  • hu8

  • hu12

  • state

dt

data.frame output of lagosne_load

Examples

## Not run: 
query_lagos_names("_dep_")
query_lagos_names("_dep_", "hu4")
query_lagos_names("chla")
query_lagos_names("secchi")
query_lagos_names("conn")

## End(Not run)