Fetch NASA POWER Data for Multiple Locations with a Progress Bar
get_nasapower.Rd
This function downloads daily NASA POWER data for specified weather variables over a specified number of days around a given date column for multiple locations. It includes a progress bar to show the download progress.
Usage
get_nasapower(
data,
days_around,
date_col,
pars = c("T2M", "RH2M", "PRECTOTCORR", "T2M_MAX", "T2M_MIN", "T2MDEW")
)
Arguments
- data
A data frame containing the input data, including columns for latitude, longitude, study identifier, and the date column.
- days_around
An integer specifying the number of days before and after the date in the date column to download data.
- date_col
A character string specifying the name of the date column in the data frame.
- pars
A character vector specifying the weather variables to fetch from NASA POWER (default: c("T2M", "RH2M", "PRECTOTCORR", "T2M_MAX", "T2M_MIN", "T2MDEW")).
Value
A data frame with the downloaded weather data from NASA POWER, combined for all specified locations.
Includes a new variable study
indicating the study identifier from the input data.
Returns an empty data frame if no data is retrieved.
Details
The function uses the get_power
function from the nasapower
package to fetch weather data for a range of
dates around the specified date column for each location. A progress bar is shown during the data download
process, and the results are combined into a single data frame.
Examples
if (FALSE) {
# Sample data
data <- data.frame(
study = c("Study1", "Study2"),
latitude = c(-15.78, -20.45),
longitude = c(-47.93, -54.82),
heading = c("2022-05-10", "2022-05-15")
)
# Fetch weather data with a progress bar
results <- get_nasapower(data, days_around = 28, date_col = "heading")
}