### Setup Development Environment with usethis Source: https://github.com/usa-npn/rnpn/blob/master/CONTRIBUTING.md Installs the devtools package and configures the R environment for development. usethis::use_devtools() adds a line to .Rprofile for automatic loading, and usethis::git_sitrep() helps manage GitHub PATs. ```R install.packages("devtools") usethis::use_devtools() usethis::git_sitrep() ``` -------------------------------- ### Install rnpn Package Source: https://github.com/usa-npn/rnpn/blob/master/docs/index.html Installs the rnpn package from CRAN or the development version from GitHub. It also loads the library for use. Dependencies like curl and gdal might require system-level installations. ```R install.packages("rnpn") install.packages("devtools") library('devtools') devtools::install_github("usa-npn/rnpn") library('rnpn') ``` -------------------------------- ### Install and Load rnpn Package in R Source: https://context7.com/usa-npn/rnpn/llms.txt Demonstrates how to install the rnpn package from CRAN or GitHub and load it into an R session. This is the first step to using the package's functionalities. ```r # Install from CRAN install.packages("rnpn") # Or install development version from GitHub install.packages("devtools") devtools::install_github("usa-npn/rnpn") # Load the package library(rnpn) ``` -------------------------------- ### Install rnpn Development Version Source: https://github.com/usa-npn/rnpn/blob/master/README.md Installs the latest development version of the rnpn package directly from GitHub using the devtools package. This requires having devtools installed. ```r install.packages("devtools") library('devtools') devtools::install_github("usa-npn/rnpn") ``` -------------------------------- ### Install rnpn from CRAN Source: https://github.com/usa-npn/rnpn/blob/master/README.md Installs the stable version of the rnpn package from the Comprehensive R Archive Network (CRAN). ```r install.packages("rnpn") ``` -------------------------------- ### Install System Dependencies for rnpn on Ubuntu Source: https://github.com/usa-npn/rnpn/blob/master/README.md Installs necessary system libraries required for the curl and gdal packages, which are dependencies of rnpn. This is typically needed on Linux-based systems like Ubuntu. ```bash sudo apt install libcurl4-openssl-dev sudo apt install libproj-dev libgdal-dev ``` -------------------------------- ### Get Abundance Categories Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_abundance_categories.html Fetches data on all abundance/intensity categories and provides a data frame of applicable values for each category. ```APIDOC ## GET /npn_abundance_categories ### Description Retrieves data on all abundance and intensity categories, including a data frame of applicable abundance/intensity values for each category. ### Method GET ### Endpoint /npn_abundance_categories ### Parameters #### Query Parameters - **...** (any) - Optional - Curl options passed on to `httr::GET` ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **abundance_categories** (data.frame) - A data frame containing abundance and intensity categories. - **applicable_values** (data.frame) - A data frame listing applicable values for each category. #### Response Example ```json { "abundance_categories": [ { "category_id": 1, "category_name": "Abundance", "description": "Number of individuals observed." }, { "category_id": 2, "category_name": "Intensity", "description": "Degree of expression of a phenophot." } ], "applicable_values": [ { "category_id": 1, "value": "Few", "value_description": "A small number of individuals." }, { "category_id": 1, "value": "Many", "value_description": "A large number of individuals." }, { "category_id": 2, "value": "Low", "value_description": "Low expression of the phenophot." }, { "category_id": 2, "value": "High", "value_description": "High expression of the phenophot." } ] } ``` ``` -------------------------------- ### Get Additional Layers Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/get_additional_rasters.html Retrieves arbitrary raster data from NPN Geospatial data services based on layer names and subset parameters. ```APIDOC ## GET /geoserver/rnpn/wms ### Description Utility function to easily take arbitrary layer name parameters as a data frame and return the raster data from NPN Geospatial data services. ### Method GET ### Endpoint /geoserver/rnpn/wms ### Parameters #### Query Parameters - **data** (data.frame) - Required - A data frame with the first column named 'name' containing layer names and the second column named 'param' containing string representations of the time/elevation subset parameter. ### Request Example ```json { "data": [ {"name": "layer1", "param": "time=2023-01-01/2023-12-31&elevation=0/3000"}, {"name": "layer2", "param": "time=2023-06-01/2023-08-31"} ] } ``` ### Response #### Success Response (200) - **raster_data** (data.frame) - A data frame containing the raster objects related to the specified layers. #### Response Example ```json { "raster_data": [ { "layer1": "" }, { "layer2": "" } ] } ``` ``` -------------------------------- ### Run R CMD Check for Package Integrity Source: https://github.com/usa-npn/rnpn/blob/master/CONTRIBUTING.md Installs development dependencies and runs R CMD check to ensure the package meets standard checks. This should be run before creating a pull request. ```R devtools::install_dev_deps() devtools::check() ``` -------------------------------- ### Get Pheno Classes Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_pheno_classes.html Retrieves information about all pheno classes, which are higher-level orders of phenophases. This function is part of the rnpn package. ```APIDOC ## GET /pheno_classes ### Description Gets information about all pheno classes, which are a higher-level order of phenophases. ### Method GET ### Endpoint /pheno_classes ### Parameters #### Query Parameters * **...** (any) - Optional - Curl options passed on to `GET` ### Request Example ```json { "example": "No specific request body example, as this is a GET request." } ``` ### Response #### Success Response (200) * **pheno_classes** (list) - A list containing information about pheno classes. #### Response Example ```json { "example": "[List of pheno class objects with their respective details]" } ``` ``` -------------------------------- ### Load rnpn Package Source: https://github.com/usa-npn/rnpn/blob/master/README.md Loads the rnpn package into the current R session, making its functions available for use. This command should be run after the package has been installed. ```r library('rnpn') ``` -------------------------------- ### Get Custom AGDD Time Series Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_get_custom_agdd_time_series.html Retrieves a custom Growing Degree Day (GDD) time series for a given location, start date, end date, and AGDD calculation parameters. This function utilizes the USA-NPN geo web services. ```APIDOC ## GET /usa-npn/rnpn/agdd-time-series ### Description Retrieves a custom Growing Degree Day (GDD) time series for a given location, start date, end date, and AGDD calculation parameters. This function utilizes the USA-NPN geo web services. ### Method GET ### Endpoint /usa-npn/rnpn/agdd-time-series ### Parameters #### Query Parameters - **method** (string) - Required - The AGDD calculation method to use. Accepts 'simple' or 'double-sine'. - **start_date** (date) - Required - The start date for the AGDD calculations (YYYY-MM-DD). - **end_date** (date) - Required - The end date for the AGDD calculations (YYYY-MM-DD). - **base_temp** (number) - Required - The base temperature for AGDD calculation. - **climate_data_source** (string) - Required - The climate data source. Accepts 'PRISM' or 'NCEP'. - **temp_unit** (string) - Required - The temperature unit. Accepts 'Fahrenheit' or 'Celsius'. - **lat** (number) - Required - The latitude of the location. - **long** (number) - Required - The longitude of the location. - **upper_threshold** (number) - Optional - The upper temperature threshold for the 'double-sine' method. ### Request Example ``` GET /usa-npn/rnpn/agdd-time-series?method=simple&start_date=2023-01-01&end_date=2023-12-31&base_temp=5&climate_data_source=PRISM&temp_unit=Fahrenheit&lat=40.0&long=-105.0 ``` ### Response #### Success Response (200) - **dates** (array of strings) - The dates for which AGDD was calculated. - **agdd** (array of numbers) - The calculated AGDD values for each date. #### Response Example ```json { "dates": ["2023-01-01", "2023-01-02", ...], "agdd": [0.0, 0.5, ...] } ``` ``` -------------------------------- ### Download Site Phenometrics with Gridded Data (R) Source: https://github.com/usa-npn/rnpn/blob/master/docs/articles/VII_combine_raster_point.html Downloads site phenometrics data and optionally includes gridded layer values for each observation. This function is useful for comparing observational data with modeled data for specific phenophases and species. It requires specifying request source, years, quality filters, species, phenophases, and download path, with additional arguments for controlling gridded data inclusion. ```r npn_download_site_phenometrics( request_source = 'Your Name Here', years = '2013', num_days_quality_filter = '30', species_ids = '35', phenophase_ids = '373', download_path = 'cl_lilac_data_2013_SIxLeaf.csv', six_leaf_layer = TRUE, six_sub_model = 'lilac' ) ``` -------------------------------- ### Create Release Issue Checklist with usethis Source: https://github.com/usa-npn/rnpn/blob/master/CONTRIBUTING.md Creates a GitHub issue with a checklist to guide the release process for the rnpn package. It helps ensure all necessary steps are taken before making a new release and prompts for the release type (major, minor, or patch). ```r usethis::use_release_issue() ``` -------------------------------- ### Get Custom AGDD Raster Map using R Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_get_custom_agdd_raster.html This R function retrieves a custom AGDD raster map from USA-NPN geo web services. It requires specifying the AGDD calculation method, climate data source, temperature unit, start and end dates, base temperature, and optionally an upper threshold for the double-sine method. ```R npn_get_custom_agdd_raster( method, climate_data_source, temp_unit, start_date, end_date, base_temp, upper_threshold = NULL ) ``` -------------------------------- ### NPN Magnitude Phenometrics Download Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_magnitude_phenometrics.html This endpoint allows users to download magnitude phenometrics data based on specified search parameters. Users can filter data by dataset IDs, species, taxonomic or phenological classifications, geographic location (WKT), and time ranges. Optional parameters include user identification (request_source), email, IP address, and a download path for saving results. ```APIDOC ## POST /usa-npn/rnpn ### Description Retrieves magnitude phenometrics data based on user-defined search parameters. This endpoint provides detailed measures of phenophase expression over time, summarized weekly, bi-weekly, monthly, or over custom intervals. Data can be filtered by various criteria including species, taxonomic groups, phenological classifications, geographic boundaries, and date ranges. User identification is required, with optional fields for email and IP address for reporting purposes. Results can be returned directly or redirected to a specified file path. ### Method POST ### Endpoint /usa-npn/rnpn ### Parameters #### Query Parameters - **dataset_ids** (List[int]) - Required - List of unique IDs for searching based on dataset (e.g., NEON, GRSM). - **email** (string) - Optional - Email of the user requesting data. - **download_path** (string) - Optional - File path to which search results should be re-directed. - **taxonomy_aggregate** (boolean) - Optional - Boolean value indicating whether to aggregate data by a taxonomic order higher than species. Ignored if `family_ids`, `order_ids`, or `class_ids` are not set. - **pheno_class_aggregate** (boolean) - Optional - Boolean value indicating whether to aggregate data by the `pheno_class_ids`. Ignored if `pheno_class_ids` is not set. - **wkt** (string) - Optional - WKT geometry by which to filter data. Filters data based on locations within the specified WKT for the contiguous US. #### Request Body - **request_source** (string) - Required - A self-identifying string indicating who is requesting the data (e.g., name or organization). - **years** (List[int]) - Required - List of years for which to retrieve data. - **species_id** (List[int]) - Optional - List of species IDs to filter results. - **family_ids** (List[int]) - Optional - List of family IDs to filter results. - **order_ids** (List[int]) - Optional - List of order IDs to filter results. - **class_ids** (List[int]) - Optional - List of class IDs to filter results. - **pheno_class_ids** (List[int]) - Optional - List of phenological class IDs to filter results. - **start_date** (string) - Optional - Start date for the data query (YYYY-MM-DD). - **end_date** (string) - Optional - End date for the data query (YYYY-MM-DD). ### Request Example ```json { "request_source": "Your Name or Org Here", "years": [2013], "species_id": [210], "download_path": "saguaro_data_2013.json" } ``` ### Response #### Success Response (200) - **data** (Array[Object]) - A data table of all status records returned as per the search parameters. Null if output is directed to a file. - **individual_id** (string) - Unique identifier for the individual plant or animal. - **year** (integer) - Year of the observation. - **week** (integer) - Week of the year for the observation. - **day_of_year** (integer) - Day of the year for the observation. - **date** (string) - Date of the observation (YYYY-MM-DD). - **latitude** (float) - Latitude of the observation site. - **longitude** (float) - Longitude of the observation site. - **pheno_class_id** (integer) - Identifier for the phenological class. - **pheno_class_name** (string) - Name of the phenological class. - **observed_status** (integer) - The observed status of the phenophase (e.g., 0 for No, 1 for Yes). - **status_start_date** (string) - The start date of the observed status (YYYY-MM-DD). - **status_end_date** (string) - The end date of the observed status (YYYY-MM-DD). - **count** (integer) - Number of individuals observed with this status. - **mean_individual_count** (float) - Mean count of individuals across sites for this status. - **proportion_observed** (float) - Proportion of individuals observed with this status. - **first_yes** (string) - Date of the first observation of 'Yes' for this phenophase. - **last_yes** (string) - Date of the last observation of 'Yes' for this phenophase. - **peak_yes_date** (string) - Date of the peak observation of 'Yes' for this phenophase. - **peak_yes_proportion** (float) - Proportion of individuals observed with 'Yes' during the peak period. - **peak_yes_count** (integer) - Count of individuals observed with 'Yes' during the peak period. - **total_yes_days** (integer) - Total number of days with 'Yes' observations. - **total_days** (integer) - Total number of days with any observation. #### Response Example ```json { "data": [ { "individual_id": "P001", "year": 2013, "week": 10, "day_of_year": 70, "date": "2013-03-11", "latitude": 32.123, "longitude": -110.456, "pheno_class_id": 1, "pheno_class_name": "Breaking Bud", "observed_status": 1, "status_start_date": "2013-03-10", "status_end_date": "2013-03-15", "count": 5, "mean_individual_count": 2.5, "proportion_observed": 0.8, "first_yes": "2013-03-09", "last_yes": "2013-03-14", "peak_yes_date": "2013-03-11", "peak_yes_proportion": 0.9, "peak_yes_count": 6, "total_yes_days": 15, "total_days": 20 } ] } ``` #### Error Response (400) - **error** (string) - Description of the error (e.g., missing required parameters, invalid input format). ``` -------------------------------- ### Run Unit Tests with Testthat Source: https://github.com/usa-npn/rnpn/blob/master/CONTRIBUTING.md Executes unit tests written using the testthat package. Tests are located in the 'tests/testthat/' directory. The vcr package is used for webmocking API responses. ```R devtools::test() # To regenerate VCR cassettes, delete relevant .yml files and re-run tests. ``` -------------------------------- ### Get NPN Datasets List - R Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_datasets.html Retrieves a data frame containing information about all datasets integrated into the NPN. This function can accept curl options to modify the GET request. The output is a data frame of datasets and their IDs. ```R npn_datasets() ``` -------------------------------- ### Download Geospatial and Individual Phenometrics Data (R) Source: https://github.com/usa-npn/rnpn/blob/master/docs/articles/VII_combine_raster_point.html This snippet shows how to download both gridded geospatial data (e.g., Spring Index models) and individual phenometrics observations. It's used to prepare data for plotting and comparing modeled predictions against actual observations. Requires specifying the geospatial layer, date range, and observational parameters like request source, years, species, and phenophases. ```r LilacLeaf2018<-npn_download_geospatial( 'si-x:lilac_leaf_ncep_historic', '2018-01-01' ) LilacLeaf2018Obs <-npn_download_individual_phenometrics( request_source = 'Your Name Here', years = '2018', species_ids = '35', phenophase_ids = '373' ) ``` -------------------------------- ### Get Species Types from NPN Database (R) Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_species_types.html Retrieves functional types (e.g., plant or animal) from the NPN database. It requires the 'Plantae' or 'Animalia' kingdom as input and can accept additional curl options for the GET request. This function is part of the rnpn package. ```R npn_species_types(kingdom = "Plantae", ...) ``` -------------------------------- ### Download Individual Phenometrics Data Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_individual_phenometrics.html This function downloads individual phenometrics data based on specified criteria. It allows filtering by years, species, and can redirect output to a specified file path. The 'request_source' parameter is mandatory. ```r if (FALSE) { #Download all saguaro data for 2013 and 2014 npn_download_individual_phenometrics( request_source="Your Name or Org Here", years=c('2013','2014'), species_id=c(210), download_path="saguaro_data_2013_2014.json" ) } ``` -------------------------------- ### Individual Phenometrics Data Retrieval Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_individual_phenometrics.html This endpoint allows you to download individual phenometrics data. You can filter data by various parameters such as years, species, and geographic location. Additionally, you can request supplementary data layers like spring index (leafing and blooming), accumulated growing degree days (AGDD), and custom geospatial layers. ```APIDOC ## GET /individual_phenometrics ### Description Retrieves individual phenometrics data, including estimates of phenophase onsets and ends for individual plants and animal species at a site. ### Method GET ### Endpoint /individual_phenometrics ### Parameters #### Query Parameters - **request_source** (string) - Required - A self-identifying string indicating the source of the request (e.g., your name or organization). - **request_user_email** (string) - Optional - Email address for usage data reporting. - **request_user_ip** (string) - Optional - IP address for usage data reporting. - **years** (array of strings) - Optional - An array of years for which to retrieve data (e.g., `["2023", "2024"]`). - **species_id** (array of integers) - Optional - An array of species IDs to filter the results. - **pheno_id** (array of integers) - Optional - An array of phenophase IDs to filter the results. - **site_id** (array of integers) - Optional - An array of site IDs to filter the results. - **observation_date_min** (string) - Optional - Minimum observation date in 'YYYY-MM-DD' format. - **observation_date_max** (string) - Optional - Maximum observation date in 'YYYY-MM-DD' format. - **download_path** (string) - Optional - File path to which search results should be redirected for later use. - **six_leaf_layer** (boolean) - Optional - If true, attempts to resolve the date of the observation to a spring index, leafing value for the location. - **six_bloom_layer** (boolean) - Optional - If true, attempts to resolve the date of the observation to a spring index, blooming value for the location. - **agdd_layer** (integer) - Optional - If set to 32 or 50, attempts to resolve the date of the observation to an AGDD value for the location. Base value is 32 or 50. - **six_sub_model** (string) - Optional - Affects the results of `six_leaf_layer` and `six_bloom_layer`. Valid values: 'lilac', 'zabelli', 'arnoldred'. - **additional_layers** (array of objects) - Optional - An array of objects, where each object has 'name' (layer name) and 'param' (time/elevation subset parameter) fields, to append additional geospatial layer data. - **wkt** (string) - Optional - WKT geometry by which to filter data. Filters data based on locations falling within the specified WKT. ### Request Example ```json { "request_source": "Your Name or Org Here", "years": ["2023", "2024"], "species_id": [210], "six_leaf_layer": true, "agdd_layer": 32, "wkt": "POLYGON((-109.05 37.0, -102.05 37.0, -102.05 41.0, -109.05 41.0, -109.05 37.0))" } ``` ### Response #### Success Response (200) - **observation_data** (array of objects) - Data table of all status records returned as per the search parameters. Each object represents a series of consecutive "yes" phenophase status records. - **observation_date** (string) - The date of the observation. - **phenodate** (string) - The date of the phenophase onset or end. - **species_id** (integer) - The ID of the species. - **pheno_id** (integer) - The ID of the phenophase. - **site_id** (integer) - The ID of the site. - **observation_count** (integer) - The number of observations. - **year** (integer) - The year of the observation. - **day_of_year** (integer) - The day of the year for the observation. - **latitude** (number) - The latitude of the observation location. - **longitude** (number) - The longitude of the observation location. - **six_leaf_value** (number) - The resolved six leaf value for the observation date and location (if requested). - **six_bloom_value** (number) - The resolved six bloom value for the observation date and location (if requested). - **agdd_value** (number) - The resolved AGDD value for the observation date and location (if requested). - **additional_layer_values** (object) - Key-value pairs for any additional layers requested. #### Response Example ```json { "observation_data": [ { "observation_date": "2023-04-15", "phenodate": "2023-04-10", "species_id": 123, "pheno_id": 1, "site_id": 456, "observation_count": 5, "year": 2023, "day_of_year": 105, "latitude": 39.7392, "longitude": -104.9903, "six_leaf_value": 1.5, "agdd_value": 150.7, "additional_layer_values": { "precipitation": 2.5 } } ] } ``` #### Error Response (400) - **error** (string) - Description of the error. #### Error Response Example ```json { "error": "Invalid request parameters. Missing required field: request_source." } ``` ``` -------------------------------- ### Get All Species Information Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_species.html Retrieves a complete list of all species information available in the NPN database. This function does not require any arguments. ```R npn_species() ``` -------------------------------- ### GET /npn_stations_by_state Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_stations_by_state.html Retrieves the total number of NPN stations organized by state. This endpoint is useful for understanding the geographic distribution of data collection sites. ```APIDOC ## GET /npn_stations_by_state ### Description Retrieves the total number of NPN stations organized by state. This endpoint is useful for understanding the geographic distribution of data collection sites. ### Method GET ### Endpoint /npn_stations_by_state ### Parameters #### Query Parameters This endpoint does not have specific query parameters documented, but accepts general Curl options passed on to `httr::GET`. ### Request Example ```json { "example": "No request body for this GET request" } ``` ### Response #### Success Response (200) - **data.frame** - A data frame containing the number of stations by state. #### Response Example ```json { "example": "data.frame(state = c('CA', 'TX', ...), num_stations = c(150, 120, ...))" } ``` ``` -------------------------------- ### Download Saguaro Data for 2016 Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_status_data.html This example demonstrates how to download all saguaro observation data for the year 2016. It specifies the request source, the year, the species ID for saguaro, and the desired download path for the output file. ```r if (FALSE) { #Download all saguaro data for 2016 npn_download_status_data( request_source="Your Name or Org Here", years=c(2016), species_id=c(210), download_path="saguaro_data_2016.json" ) } ``` -------------------------------- ### Get Species Information by ID Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_species.html Retrieves information about a specific species based on its NPN unique ID. Accepts a list of species IDs as input. ```R npn_species_id(ids = 3) ``` -------------------------------- ### Get Phenophase Details Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_phenophase_details.html Retrieves additional details for select phenophases, including the full list of applicable phenophase definition IDs and phenophase revision notes over time. ```APIDOC ## GET /phenophases ### Description Retrieves additional details for select phenophases, including the full list of applicable phenophase definition IDs and phenophase revision notes over time. ### Method GET ### Endpoint /phenophases ### Parameters #### Query Parameters - **ids** (integer or character) - Required - A list of phenophase IDs for which to retrieve additional details. #### Request Body None ### Response #### Success Response (200) - **phenophases** (list) - A list containing detailed information for each requested phenophase. - **phenophase_id** (integer) - The unique identifier for the phenophase. - **phenophase_name** (character) - The name of the phenophase. - **definition** (character) - A detailed description of the phenophase. - **active_start_date** (character) - The date when the phenophase definition became active (YYYY-MM-DD). - **active_end_date** (character) - The date when the phenophase definition became inactive (YYYY-MM-DD), or null if still active. - **notes** (character) - Revision notes or historical information about the phenophase. #### Response Example ```json { "phenophases": [ { "phenophase_id": 1, "phenophase_name": "Breaking Bud", "definition": "The first time leaves are observed unfolding. For species with buds, this is the opening of the leaf buds. For species without buds, this is the emergence of the first leaves.", "active_start_date": "2018-01-01", "active_end_date": null, "notes": "Initial definition." }, { "phenophase_id": 2, "phenophase_name": "Full Leaf", "definition": "The time when the plant has all its leaves for the current growing season.", "active_start_date": "2018-01-01", "active_end_date": null, "notes": "Initial definition." } ] } ``` ``` -------------------------------- ### Download Saguaro Data for 2013 using R Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_magnitude_phenometrics.html This R code snippet demonstrates how to download magnitude phenometrics data for saguaro species in the year 2013. It specifies the request source, the year, the species ID, and the download path for the output file. ```r if (FALSE) { #Download book all saguaro data for 2013 npn_download_magnitude_phenometrics( request_source="Your Name or Org Here", years=c(2013), species_id=c(210), download_path="saguaro_data_2013.json" ) } ``` -------------------------------- ### Download Magnitude Phenometrics with rnpn Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_magnitude_phenometrics.html This R function `npn_download_magnitude_phenometrics` queries the USA-NPN database for magnitude phenometrics. It accepts numerous parameters for filtering data by year, location, species, and more. The function returns data as a data table and can optionally save raw JSON output to a specified file path, which is useful for handling large datasets. ```R npn_download_magnitude_phenometrics( request_source, years, period_frequency = "30", coords = NULL, species_ids = NULL, genus_ids = NULL, family_ids = NULL, order_ids = NULL, class_ids = NULL, pheno_class_ids = NULL, station_ids = NULL, species_types = NULL, network_ids = NULL, states = NULL, phenophase_ids = NULL, functional_types = NULL, additional_fields = NULL, climate_data = FALSE, ip_address = NULL, dataset_ids = NULL, email = NULL, download_path = NULL, taxonomy_aggregate = NULL, pheno_class_aggregate = NULL, wkt = NULL ) ``` -------------------------------- ### Get Partner Groups Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_groups.html Retrieves a list of all groups participating in the NPN's data collection program. This information can be used to filter results from other API endpoints. ```APIDOC ## GET /npn/groups ### Description Returns a list of all groups participating in the NPN's data collection program. These details can be used to further filter other service endpoints' results. ### Method GET ### Endpoint /npn/groups ### Query Parameters - **use_hierarchy** (boolean) - Optional - Boolean indicating whether or not the list of networks should be represented in a hierarchy. Defaults to FALSE ### Request Example ```json { "use_hierarchy": false } ``` ### Response #### Success Response (200) - **partnerGroups** (array) - A list of partner groups, where each group contains an 'id' and 'name'. #### Response Example ```json { "partnerGroups": [ { "id": 1, "name": "Example Group 1" }, { "id": 2, "name": "Example Group 2" } ] } ``` ``` -------------------------------- ### Download Site Phenometrics using R Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_site_phenometrics.html This R function `npn_download_site_phenometrics` queries the USA-NPN database for site phenometrics. It accepts numerous parameters to filter the search, such as years, geographic coordinates, species IDs, and network IDs. The function returns raw JSON data, which can be processed into a data table or saved directly to a CSV file. It is useful for retrieving and analyzing phenological data across different sites and species. ```r npn_download_site_phenometrics( request_source, years, num_days_quality_filter = "30", coords = NULL, species_ids = NULL, genus_ids = NULL, family_ids = NULL, order_ids = NULL, class_ids = NULL, pheno_class_ids = NULL, station_ids = NULL, species_types = NULL, network_ids = NULL, states = NULL, phenophase_ids = NULL, functional_types = NULL, additional_fields = NULL, climate_data = FALSE, ip_address = NULL, dataset_ids = NULL, email = NULL, download_path = NULL, six_leaf_layer = FALSE, six_bloom_layer = FALSE, agdd_layer = NULL, six_sub_model = NULL, additional_layers = NULL, taxonomy_aggregate = NULL, pheno_class_aggregate = NULL, wkt = NULL ) ``` -------------------------------- ### Get Stations with Species Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_stations_with_spp.html Retrieves a list of all stations that have individuals belonging to a specified set of species. This endpoint is useful for identifying monitoring sites based on species presence. ```APIDOC ## GET /stations/with_species ### Description Get a list of all stations which have an individual whom is a member of a set of species. ### Method GET ### Endpoint /stations/with_species ### Parameters #### Query Parameters - **speciesid** (numeric) - Required - Species id numbers, from 1 to infinity, potentially, use e.g., c(52, 53, etc.) if more than one species desired. - **...** (any) - Optional - Curl options passed on to `httr::GET` ### Request Example ```json { "speciesid": [52, 53, 54] } ``` ### Response #### Success Response (200) - **station_id** (integer) - The unique identifier for the station. - **station_name** (string) - The name of the station. - **latitude** (numeric) - The latitude coordinate of the station. - **longitude** (numeric) - The longitude coordinate of the station. #### Response Example ```json { "stations": [ { "station_id": 1, "station_name": "Station A", "latitude": 34.0522, "longitude": -118.2437 }, { "station_id": 2, "station_name": "Station B", "latitude": 40.7128, "longitude": -74.0060 } ] } ``` ``` -------------------------------- ### Initialize a New Branch for a Pull Request Source: https://github.com/usa-npn/rnpn/blob/master/CONTRIBUTING.md Creates a new Git branch for a pull request using usethis. The branch name should briefly describe the intended changes. ```R usethis::pr_init("brief-description-of-change") ``` -------------------------------- ### Download Site Phenometrics Source: https://github.com/usa-npn/rnpn/blob/master/docs/reference/npn_download_site_phenometrics.html This function allows for a parameterized search of all site phenometrics records in the USA-NPN database, returning all records as per the search parameters in a data table. Data fetched from NPN services is returned as raw JSON before being channeled into a data table. Optionally results can be directed to an output file in which case raw JSON is converted to CSV and saved to file; in that case, data is also streamed to file which allows for more easily handling of the data if the search otherwise returns more data than can be handled at once in memory. ```APIDOC ## POST /npn_download_site_phenometrics ### Description Allows for a parameterized search of all site phenometrics records in the USA-NPN database, returning records as per the search parameters in a data table. Data is fetched as raw JSON, optionally converted to CSV and saved to file. ### Method POST ### Endpoint /npn_download_site_phenometrics ### Parameters #### Query Parameters - **request_source** (string) - Required - Self-identify who is making requests to the data service. - **years** (list of strings) - Required - Specify the years to include in the search, e.g. c('2013','2014'). You must specify at least one year. - **num_days_quality_filter** (string) - Optional, defaults to "30" - The integer value sets the upper limit on the number of days difference between the first Y value and the previous N value for each individual to be included in the data aggregation. - **coords** (list of float) - Optional - Used to specify a bounding box as a search parameter, e.g. c ( lower_left_lat, lower_left_long, upper_right_lat, upper_right_long ). - **species_ids** (list of unique IDs) - Optional - For searching based on species, e.g. c ( 3, 34, 35 ). - **genus_ids** (list of unique IDs) - Optional - For searching based on taxonomic family, e.g. c ( 3, 34, 35 ). This parameter will take precedence if species_ids is also set. - **family_ids** (list of unique IDs) - Optional - For searching based on taxonomic family, e.g. c ( 3, 34, 35 ). This parameter will take precedence if species_ids is also set. - **order_ids** (list of unique IDs) - Optional - For searching based on taxonomic order, e.g. c ( 3, 34, 35 ). This parameter will take precedence if species_ids or family_ids are also set. - **class_ids** (list of unique IDs) - Optional - For searching based on taxonomic class, e.g. c ( 3, 34, 35 ). This parameter will take precedence if species_ids, family_ids or order_ids are also set. - **pheno_class_ids** (list of unique IDs) - Optional - For searching based on pheno class id, e.g. c (1, 5, 13). - **station_ids** (list of unique IDs) - Optional - For searching based on site location, e.g. c ( 5, 9, ... ). - **species_types** (list of strings) - Optional - For searching based on species types, e.g. c ( "Deciduous", "Evergreen" ). - **network_ids** (list of unique IDs) - Optional - For searching based on partner group/network, e.g. ( 500, 300, ... ). - **states** (list of strings) - Optional - US postal states to be used as search params, e.g. c ( "AZ", "IL" ). - **phenophase_ids** (list of unique IDs) - Optional - For searching based on phenophase, e.g. c ( 323, 324, ... ). - **functional_types** (list of strings) - Optional - For searching based on functional types, e.g. c ( "Birds" ). - **additional_fields** (list of strings) - Optional - Additional fields to be included in the search results, e.g. ( "Station_Name", "Plant_Nickname" ). - **climate_data** (boolean) - Optional - Indicates that all climate variables should be included in additional_fields. - **ip_address** (string) - Optional - IP Address of user requesting data. Used for generating data reports. - **dataset_ids** (list of unique IDs) - Optional - For searching based on dataset, e.g. NEON or GRSM c(17,15). - **email** (string) - Optional - Email of user requesting data. - **download_path** (string) - Optional - Path to save the downloaded data. - **six_leaf_layer** (boolean) - Optional - Include six leaf layer data. - **six_bloom_layer** (boolean) - Optional - Include six bloom layer data. - **agdd_layer** (any) - Optional - Include AGDD layer data. - **six_sub_model** (any) - Optional - Include six sub-model data. - **additional_layers** (any) - Optional - Include additional layers. - **taxonomy_aggregate** (any) - Optional - Aggregate by taxonomy. - **pheno_class_aggregate** (any) - Optional - Aggregate by pheno class. - **wkt** (string) - Optional - Well-Known Text geometry for spatial filtering. ### Request Example ```json { "request_source": "Example User", "years": ["2022", "2023"], "species_ids": [123, 456], "download_path": "/path/to/save/data.csv" } ``` ### Response #### Success Response (200) - **data** (table) - The downloaded site phenometrics data. - **raw_json** (JSON) - Raw JSON response from the NPN service. #### Response Example ```json { "data": [ { "year": 2022, "site_id": 101, "pheno_date": "2022-05-15", "pheno_status": "leaf_out", "species_id": 123 }, { "year": 2023, "site_id": 102, "pheno_date": "2023-06-01", "pheno_status": "flowering", "species_id": 456 } ], "raw_json": "..." } ``` ``` -------------------------------- ### Get Station Data - R Source: https://context7.com/usa-npn/rnpn/llms.txt Retrieves a list of all observation stations within the NPN. Can be optionally filtered by one or more state codes to get stations in specific geographic regions. ```r # Get all stations all_stations <- npn_stations() # Get stations in Arizona az_stations <- npn_stations(state_code = "AZ") # Get stations in multiple states sw_stations <- npn_stations(state_code = c("AZ", "NM", "CO", "UT")) ``` -------------------------------- ### Load Package for Interactive Testing Source: https://github.com/usa-npn/rnpn/blob/master/CONTRIBUTING.md Loads all functions and data from the package into the current R session, simulating the behavior of a loaded package. This allows for interactive testing of changes. ```R devtools::load_all() ```