Title: | Process NEON Plant Data for Ecological Analysis |
---|---|
Description: | Downloading and organizing plant presence and percent cover data from the National Ecological Observatory Network <https://www.neonscience.org>. |
Authors: | Adam Mahood [aut, cre], Jacob Macdonald [ctb], Ranjan Muthukrishnan [ctb] |
Maintainer: | Adam Mahood <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.6.1 |
Built: | 2025-03-09 05:28:26 UTC |
Source: | https://github.com/admahood/neonplantecology |
This includes Jornada Experimental Range and Santa Rita Experimental Range
D14
D14
## 'D14' A list with 8 items, 2 of which are used by neonPlantEcology
<https://doi.org/10.48443/9579-a253>
<https://data.neonscience.org/data-products/DP1.10058.001>
Sometimes even though a particular species identity is not known, the end user can still determine its native status. For example, maybe the taxon was identified to the genus level, and the local flora confirms that all plants in that genus are native at that particular site. This function allows for post-hoc modification of the native status code for cases like this.
npe_change_native_status(df, taxon, site, new_code)
npe_change_native_status(df, taxon, site, new_code)
df |
is the data frame returned by npe_longform |
taxon |
is the taxonID column in the data frame |
site |
is the identity of the NEON site (e.g. "JORN") |
new_code |
is the NativeStatusCode value to change to |
a data frame
data("D14") lf_div <- npe_longform(D14) modified_lf_div <- npe_change_native_status(lf_div, "ABUTI", "JORN", "N")
data("D14") lf_div <- npe_longform(D14) modified_lf_div <- npe_change_native_status(lf_div, "ABUTI", "JORN", "N")
The npe_community_matrix() function is designed to work with the vegan package, and one of the requirements of vegan functions is that there are only numeric columns in community matrices. Therefore, all of the metatdata is collapsed into the rownames. This function allows you to extract that very basic metadata back out to a more easily interpretable data frame.
npe_cm_metadata(comm)
npe_cm_metadata(comm)
comm |
the community matrix object created by npe_community_matrix() |
a data frame
data("D14") npe_community_matrix(D14) |> npe_cm_metadata()
data("D14") npe_community_matrix(D14) |> npe_cm_metadata()
npe_community_matrix creates a wide matrix of species cover or binary (presence/absence) values with the plot/subplot/year as rownames. This is useful for the vegan package, hence the name.
npe_community_matrix( x, scale = "plot", trace_cover = 0.5, timescale = "annual", input = "neon_div_object", binary = FALSE )
npe_community_matrix( x, scale = "plot", trace_cover = 0.5, timescale = "annual", input = "neon_div_object", binary = FALSE )
x |
Input object. See input argument help for more details. |
scale |
what level of aggregation? This can be "1m", "10m", "100m", "plot", which is the default, or "site". |
trace_cover |
cover value for subplots where only occupancy was recorded |
timescale |
what temporal resolution? can be "subannual", which is really only applicable at sites where there are multiple bouts per year, "annual" or "all", which dissolves together the entire time series. |
input |
by default, longform dataframe is calculated from the diversity object and then converted to a community matrix, set this option to "lf" to use a longform data frame that was created separately (and perhaps modified). Another option is input = "divStack", which is using the output from the divStack function in the neonPlants package. Using a premade longform data frame or a divStack output will use the spatial and temporal scale of that input data separately |
binary |
should the matrix be converted from percent cover to binary? |
neon_div_object |
the raw diversity data downloaded using neonPlantEcology::download_plant_div() or the function neonUtilities::loadByProduct() with the dpID arguement set to "DP1.10058.001". |
a data frame with each row a site aggregated at the spatial and temporal scales chosen by the user. Each column is a single species, and cell values can be either cover (a value between 0 and 100) or occurrence (1 or 0)
data("D14") comm <- npe_community_matrix(D14)
data("D14") comm <- npe_community_matrix(D14)
A wrapper function to download data from the NEON API using neonUtilities::loadByProduct. Some commonly used products are provided as plain language options, otherwise the user can enter the product ID number (dpID). Downloads Plant Presence and Percent Cover by default (DP1.10058.001).
npe_download( sites = "JORN", dpID = NA, token = NA, verbose = TRUE, product = "plant_diversity", ... )
npe_download( sites = "JORN", dpID = NA, token = NA, verbose = TRUE, product = "plant_diversity", ... )
sites |
a vector of NEON site abbreviations. Defaults to "JORN" |
dpID |
if you need a data product not given as one of the product options, set the data product ID here (e.g. "DP1.10023.001"). |
token |
a token from neonscience.org |
verbose |
if true, prints which sites are being downloaded |
product |
a plain language vector of the data product to be downloaded. Can be "plant_diversity", "litterfall", "woody_veg_structure", "belowground_biomass", "herbaceous_clip", "coarse_downed_wood", or "soil_microbe_biomass" |
... |
additional arguments can be passed to neonUtilities::loadByProduct see ?neonUtilites::loadByProduct for more details |
a list
diversity_object <- npe_download(sites = "JORN")
diversity_object <- npe_download(sites = "JORN")
neonPlantEcology is a house of cards that rests delicately upon the eventID column being in the site.bout-number.year format, and if there is any deviation from that format all hell breaks loose. This function converts any NA or non-standard eventID rows to the desired format.
npe_eventID_fixer(x, verbose = FALSE)
npe_eventID_fixer(x, verbose = FALSE)
x |
raw list data from NEON api |
verbose |
if true, prints details of which eventID errors were fixed into the console |
the same list object but with repaired eventIDs
data("D14") x <- npe_eventID_fixer(D14)
data("D14") x <- npe_eventID_fixer(D14)
Get ground cover and other variables
npe_groundcover( neon_div_object, scale = "plot", verbose = FALSE, pc_na_value = 0.5, timescale = "annual" )
npe_groundcover( neon_div_object, scale = "plot", verbose = FALSE, pc_na_value = 0.5, timescale = "annual" )
neon_div_object |
the raw diversity data downloaded using neonPlantEcology::download_plant_div() or the function neonUtilities::loadByProduct() with the dpID arguement set to "DP1.10058.001". |
scale |
the spatial scale of aggregation. Can be "1m", "10m", "100m", "plot" or "site". default is "plot". |
verbose |
if true, prints details of which eventID errors were fixed into the console |
pc_na_value |
sometimes the raw data from neon will have NA's in the percent cover cells. This is assumed to be a data entry error and is set to 0.5 by default. |
timescale |
The temporal scale of aggregation. Can be "all", "annual" or "subannual" in the case of multiple sampling bouts per year. Defaults to "annual". |
a data frame with each row a single observation of ground cover at the spatial and temporal scale chosen by the user.
data("D14") groundcover <- npe_groundcover(D14)
data("D14") groundcover <- npe_groundcover(D14)
Get heights
npe_heights( neon_div_object, scale = "plot", verbose = FALSE, timescale = "annual" )
npe_heights( neon_div_object, scale = "plot", verbose = FALSE, timescale = "annual" )
neon_div_object |
the raw diversity data downloaded using neonPlantEcology::download_plant_div() or the function neonUtilities::loadByProduct() with the dpID arguement set to "DP1.10058.001". |
scale |
the spatial scale of aggregation. Can be "1m", "10m", "100m", "plot" or "site". default is "plot". |
verbose |
if true, prints details of which eventID errors were fixed into the console |
timescale |
The temporal scale of aggregation. Can be "all", "annual" or "subannual" in the case of multiple sampling bouts per year. Defaults to "annual". |
a data frame with each row a single observation of species height at the spatial and temporal scale chosen by the user.
data("D14") heights <- npe_heights(D14)
data("D14") heights <- npe_heights(D14)
The diversity data from NEON comes as a list containing 2 data frames of data that need to be combined, among other things. Here, we take those two data frames and combine them into a longform data frame that can then be further modified for analysis. Most of the unneccessary information from the raw data has been removed. Column names that remain are plotID, subplotID, year, taxonID, cover, scientificName, nativeStatusCode, family, and site.
npe_longform( neon_div_object, trace_cover = 0.5, pc_na_value = 0.5, scale = "plot", verbose = FALSE, timescale = "annual" )
npe_longform( neon_div_object, trace_cover = 0.5, pc_na_value = 0.5, scale = "plot", verbose = FALSE, timescale = "annual" )
neon_div_object |
the raw diversity data downloaded using neonPlantEcology::download_plant_div() or the function neonUtilities::loadByProduct() with the dpID arguement set to "DP1.10058.001". |
trace_cover |
cover value for subplots where only occupancy was recorded |
pc_na_value |
sometimes the raw data from neon will have NA's in the percent cover cells. This is assumed to be a data entry error and is set to 0.5 by default. |
scale |
what level of spatial aggregation? This can be "1m", "10m", "100m", "plot", which is the default, or "site". |
verbose |
if true, prints details of which eventID errors were fixed into the console |
timescale |
what level of temporal aggregation? can be "subannual", which is only important for sites with multiple sampling bouts per year, "annual" or "all" for the full time series. |
a data frame with each row a single observation of species cover at the spatial and temporal scale chosen by the user.
data("D14") lf <- npe_longform(D14)
data("D14") lf <- npe_longform(D14)
Download and join spatial information to a neonPlantEcology output data frame
npe_plot_centroids( df, type = "latlong", spatial_only = TRUE, input = "community_matrix" )
npe_plot_centroids( df, type = "latlong", spatial_only = TRUE, input = "community_matrix" )
df |
a neonPlantEcology-produced data frame |
type |
what type of ancillary data structure you want joined. Can be "spatial", which will turn the data frame into an sf data frame, or "latlong", which will add the latitudes and longitudes and other ancillary data as columns only. |
spatial_only |
set to TRUE if you only want the coordinates and none of the ancillary variables. |
input |
to what kind of neonPlantEcology product are you appending? Can be "community_matrix", "longform_cover", or "summary_info". |
a data frame
This returns a list of 4 letter site ID codes to feed into npe_download. It can return all 47 siteID codes, or a subset based on site type, aridity index, Koppen-Geiger Climate region, or NEON domain.
npe_site_ids(by, domain = NA, type = NA, aridity = NA, koppen = NA)
npe_site_ids(by, domain = NA, type = NA, aridity = NA, koppen = NA)
by |
How to select sites? Can be "all", "domain", "ai", "koppen", or "type". |
domain |
can be one or more domain codes, as a character vector, or as a number. e.g. domain = c("D01", "D14"), or domain = c(3, 14), can also be a mix: domain = c(3, "D04). |
type |
can be "Core Terrestrial" or "Relocatable Terrestrial" |
aridity |
can be "Hyper-Arid", "Arid", "Dry sub-humid", or "Humid" |
koppen |
can be any 3 letter Koppen-Geiger code, or one of "Equatorial", "Arid", "Temperate", "Boreal", "Polar" |
a vector of four letter site identification codes.
all_sites <- npe_site_ids(by = "all") npe_site_ids(by = "domain", domain = c("Northeast", "Mid-Atlantic")) npe_site_ids(by = "domain", domain = c("D02", 15))
all_sites <- npe_site_ids(by = "all") npe_site_ids(by = "domain", domain = c("Northeast", "Mid-Atlantic")) npe_site_ids(by = "domain", domain = c("D02", 15))
npe_summary calculates various biodiversity and cover indexes at the plot or subplot scale at each timestep for each plot. Outputs a data frame with number of species, percent cover, relative percent cover (relative to the cover of the other plants), and shannon diversity, for natives, exotics, "notexotics", unknowns, and all species. "notexotic" refers to all species with native or unknown origin status. Also calculates all of these metrics for the families of your choice.
npe_summary( neon_div_object, scale = "plot", trace_cover = 0.5, timescale = "annual", betadiversity = FALSE, families = NA )
npe_summary( neon_div_object, scale = "plot", trace_cover = 0.5, timescale = "annual", betadiversity = FALSE, families = NA )
neon_div_object |
the raw vegan::diversity data downloaded using neonPlantEcology::download_plant_div() or #' the function neonUtilities::loadByProduct() with the dpID arguement set to "DP1.10058.001". |
scale |
what level of aggregation? This can be "1m", "10m", "100m", "plot" or "site". "plot" is the default. |
trace_cover |
cover value for subplots where only occupancy was recorded |
timescale |
by default npe_summary groups everything by year. The user may set this argument to "all" to have the function aggregate the years together and then calculate diversity and cover indexes, or "subannual" for bout-level. |
betadiversity |
If evaluating at the plot or site level, should beta diversity (turnover and nestedness) be calculated. If scale = plot, it will calculate betadiversity within each plot, using the combined species presences within the 1 and 10 m subplots, and so it's calcuated from 8 subplots before 2020, 6 after. if scale = site, it calculates the betadiversity between plots. |
families |
Which specific families should the metrics be calculated for? This can be a concatenated vector if the user want more than one family. |
a data frame of higher-level summary information. Number of species, Shannon-Weiner alpha diversity, cover, relative cover, for all species together and grouped by nativeStatusCode.
data("D14") plot_level <- neonPlantEcology::npe_summary(neon_div_object = D14, scale = "plot")
data("D14") plot_level <- neonPlantEcology::npe_summary(neon_div_object = D14, scale = "plot")
The 2024 release features a change in subplot names. This function changes subplot names of the Plant Presence and Percent Cover raw list object from the old format to the new format, to ensure backwards compatibility. This is mostly an internal helper function
npe_update_subplots(neon_div_object)
npe_update_subplots(neon_div_object)
neon_div_object |
a list downloaded using npe_download containing Plant Presence and Percent Cover data |
a
data("D14") D14_updated <- npe_update_subplots(D14)
data("D14") D14_updated <- npe_update_subplots(D14)
Plot centroids for the entire NEON network
plot_centroids
plot_centroids
## 'plot_centroids' A simple feature collection with 3842 features and 36 fields
<https://www.neonscience.org>
Note: Some sites have more than one polygon. There are 59 polygons and 47 total sites.
site_polygons
site_polygons
## 'site_polygons' A simple feature collection with 59 features and 8 fields
Domain Number
Domain Name
Site type. Core or Relocatable
Site name
Four letter site ID. Used in npe_download()
Organization hosting the site
Area of the site in square kilometers
Area of the site in acres
list column containing geometry information for each polygon
<https://www.neonscience.org>
Note: Some sites have more than one polygon. There are 59 polygons and 47 total sites.
sites
sites
## 'sites' data frame with 47 features and 8 fields
Domain Number
Domain Name
Site type. Core or Relocatable
Four letter site ID. Used in npe_download()
Koppen-Geiger climate classification from Beck et al 2023
Coarsest category of K-G climate classification from Beck et al 2023
Annual aridity index from Zomer & Trabucco 2022
Climate classification based on the aridity index from Zomer & Trabucco 2022
<https://www.neonscience.org>
<https://doi.org/10.6084/m9.figshare.7504448.v5>
<https://doi.org/10.1038/s41597-023–02549‑6>