Learn R Programming

weatherjoin

weatherjoin is an R package for attaching gridded weather data to event-based datasets using efficient spatio-temporal planning and local caching.

The package is designed for workflows where weather variables need to be matched to many observations across space and time, while minimising repeated data downloads.

Currently, weather data are retrieved from the NASA POWER project via the nasapower R package.

This package is not affiliated with or endorsed by NASA.

Features

  • Attach daily or hourly gridded weather data to event tables
  • Automatic planning of efficient spatio-temporal API calls
  • Local caching of downloaded weather segments for reuse
  • Exact or rolling joins for hourly data
  • Flexible handling of multiple locations (spatial clustering, grouped sites, or exact points)

Installation

The package can be installed from GitHub:

remotes::install_github("hauae/weatherjoin")

Example

library(weatherjoin)

out <- join_weather(
  x = events,
  params = c("T2M", "PRECTOTCORR"),
  time = "event_time",
  lat_col = "lat",
  lon_col = "lon"
)

Caching

Downloaded weather data are cached locally and reused across calls. By default, the cache is stored in a user-specific directory obtained via tools::R_user_dir(). The cache can be inspected and managed using:

wj_cache_list()
wj_cache_clear()

Author and affiliation

Developed by Przemek Dolowy, Harper Adams University.

License

MIT License.

Copy Link

Version

Install

install.packages('weatherjoin')

Version

0.2.2

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Przemek Dolowy

Last Published

February 4th, 2026

Functions in weatherjoin (0.2.2)

join_weather

Join gridded weather data to an event table
wj_cache_clear

Clear cached weather data
wj_cache_list

List cached weather segments
wj_cache_upgrade_index

Upgrade cache index schema
.build_time

Build standard time keys used by weatherjoin
weatherjoin_options

weatherjoin options
.elev_lookup

Placeholder elevation lookup
.split_time_ranges

Split sparse time points into segments using a gap penalty (hours)
.fetch_power

Fetch NASA POWER for planned calls
.attach_weather

Join weather back to events (supports rolling join for hourly)
.normalize_power_time

Normalize POWER output time columns to timestamp_utc (UTC)
.validate_time_components

Multi-column time input path Validate time components and build Date safely
.resolve_time_api

Resolve time_api based on user choice and input resolution
.spatial_plan

Spatial planning: map points to representative locations
weatherjoin-package

weatherjoin: Join Gridded Weather Data to Event Tables
.validate_single_time

Single-column time input path Validate and normalize a time column
.wj_opt

Get weatherjoin option with default
.map_time_columns

Multi-column time input path Map time columns to roles
.call_plan

Plan provider calls: for each loc_id, split by time sparsity
.wj_load

Internal: load required packages (used for interactive sourcing too)
.cache_check

Check cache coverage for planned calls