rnpn

Project Status: Active – The project has reached a stable, usable state and is being actively developed. cran checks codecov.io R build status

rnpn is an R client for interacting with the USA National Phenology Network data web services. These services include access to a rich set of observer-contributed, point-based phenology records as well as geospatial data products including gridded phenological model and climatological data.

Documentation is available for the National Phenology Network API documentation, which describes the full set of REST services this package wraps.

There is no need for an API key to grab data from the National Phenology Network but users are required to self identify, on an honor system, against requests that may draw upon larger datasets. Simply populate the request_source parameter, as necessary, with your name or the name of your institution.

Currently there are services for writing to the database but those endpoints do require user authentication and are not accessible through this R wrapper. Please contact the package authors for more information if that’s what you’re trying to do.

Installation

This package has evolved slowly and is currently managed in a few locations, with varying degrees of available functionality.

The original, v. 0.1, iteration of the package is available through CRAN but has limited functionality and a number of endpoints that have been deprecated.

CRAN version

install.packages("rnpn")

There’s a newer iteration of the package that includes a lot more functionality, including the ability to access geospatial data, and is up-to-date with the backing data services. This version of the package is actively maintained, but is not managed through CRAN yet and as such is more bug-prone. This version of the package must be installed through devtools.

Development version

install.packages("devtools")
library('devtools')
devtools::install_github("usa-npn/rnpn")
library('rnpn')

The Basics

Many of the functions to search for data require knowing the internal unique identifiers of some of the database entities to filter the data down efficiently. For example, if you want to search by species, then you must know the internal identifier of the species. To get a list of all available species use the following:

species_list <- npn_species()

Similarly, for phenophases:

phenophases <- npn_phenophases()

Getting Observational Data

There are four main functions for accessing observational data, at various levels of aggregation. At the most basic level you can download the raw status and intensity data.

some_data <- npn_download_status_data(request_source='Your Name or Org Here',years=c(2015),species_id=c(35),states=c('AZ','IL'))

Note that through this API, data can only be filtered chronologically by full calendar years. You can specify any number of years in each API call. Also note that request_source is a required parameter and should be populated with your name or the name of the organization you represent. All other parameters are optional but it is highly recommended that you filter your data search further.

Getting Geospatial Data

This package wraps around standard WCS endpoints to facilitate the transfer of raster data. Generally, this package does not focus on interacting with WMS services, although they are available. To get a list of all available data layers, use the following:

layers <- npn_get_layer_details()

You can then use the name of the layers to select and download geospatial data as a raster.

npn_download_geospatial(coverage_id = 'si-x:lilac_leaf_ncep_historic',date='2016-12-31',format='geotiff',output_path='./six-test-raster.tiff')

If you’re looking for a grid value at a specific latitude/longitude, that is also possible.

point_value <- npn_get_point_data('si-x:lilac_leaf_ncep_historic',date='2016-12-31',lat=38.5,long=-110.7)

What’s Next

Please read and review the vignettes for this package to get further information about the full scope of functionality available.

Meta

image