npn_get_data: Download NPN Data

View source: R/npn_data_download.R

npn_get_dataR Documentation

Download NPN Data

Description

Generic utility function for querying data from the NPN data services.

Usage

npn_get_data(
  endpoint,
  query,
  download_path = NULL,
  always_append = FALSE,
  six_leaf_raster = NULL,
  six_bloom_raster = NULL,
  agdd_layer = NULL,
  additional_layers = NULL
)

Arguments

endpoint

The endpoint to request data from starting at 'https://services.usanpn.org/npn_portal/'. E.g. "observations/getObservations.ndjson"

download_path

String, optional file path to the file for which to output the results.

always_append

Boolean flag. When set to TRUE, then we always append data to the download path. This is used in the case of npn_get_data_by_year() where we're making multiple requests to the same service and aggregating all data results in a single file. Without this flag, otherwise, each call to the service would truncate the output file.

Value

A tibble of the requested data. If a download_path was specified, the file path is returned.

Examples

## Not run: 
npn_get_data(
  endpoint = "observations/getObservations.ndjson",
  query = list(
    request_src = "Unit Test",
    climate_data = "0",
    `species_id[1]` = "6",
    start_date = "2010-01-01",
    end_date = "2010-12-31"
  )
)

## End(Not run)

rnpn documentation built on April 3, 2025, 5:54 p.m.