| join_weather | R Documentation |
Attach gridded weather variables from NASA POWER to rows of an event table. The function:
standardizes/validates time input (single timestamp column or multiple time columns),
plans efficient provider calls by clustering locations (default) and splitting sparse time ranges,
caches downloaded weather segments locally and reuses them,
joins weather back to events using exact or rolling joins.
join_weather(
x,
params,
time,
lat_col = "lat",
lon_col = "lon",
time_api = c("guess", "hourly", "daily"),
tz = "UTC",
roll = c("nearest", "last", "none"),
roll_max_hours = NULL,
spatial_mode = c("cluster", "exact", "by_group"),
group_col = NULL,
cluster_radius_m = 250,
site_elevation = c("constant", "auto"),
elev_constant = 100,
elev_fun = NULL,
community = "ag",
cache_scope = c("user", "project"),
cache_dir = NULL,
verbose = FALSE,
...
)
x |
A data.frame/data.table with event rows. |
params |
Character vector of NASA POWER parameter codes (e.g. |
time |
A single column name containing time (POSIXct/Date/character/numeric) OR
a character vector of column names used to assemble a timestamp (e.g. |
lat_col, lon_col |
Column names for latitude and longitude (decimal degrees). |
time_api |
One of |
tz |
Time zone used to interpret/construct input timestamps (default |
roll |
Join behaviour when matching timestamps: |
roll_max_hours |
Maximum allowed time distance (hours) for a rolling match. If NULL, a safe default is used: 1 hour for hourly joins and 24 hours for daily joins. |
spatial_mode |
How to reduce many points to representative locations before calling POWER:
|
group_col |
Grouping column used when |
cluster_radius_m |
Clustering radius in meters when |
site_elevation |
Elevation strategy for POWER calls: |
elev_constant |
Constant elevation (meters) used when |
elev_fun |
Optional function |
community |
Passed to |
cache_scope |
Where to store cache by default: |
cache_dir |
Optional explicit cache directory. If NULL, determined by |
verbose |
If TRUE, print progress messages. |
... |
Passed through to |
A data.table with weather columns appended. Rows with missing/invalid inputs keep their original values and receive NA weather.
wj_cache_list, wj_cache_clear, weatherjoin_options
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.