regrid: Average onto a coarser regular grid

View source: R/analysis.R

regridR Documentation

Average onto a coarser regular grid

Description

Each point goes into the cell of size resolution that contains it. The result has the cell centres, so a 0.5 degree grid has centres at x.25 and x.75, the same as CRU TS.

Usage

regrid(
  data,
  value,
  resolution,
  by = NULL,
  lat_col = "latitude",
  lon_col = "longitude"
)

Arguments

data

Data frame with latitude and longitude columns

value

Name of the column to average

resolution

Target cell size in degrees

by

Optional extra group columns, for example "year"

lat_col

Name of the latitude column

lon_col

Name of the longitude column

Value

Data frame with lat_col, lon_col, the by columns and value

Examples

df <- expand.grid(latitude = seq(10, 10.75, 0.25), longitude = seq(70, 70.75, 0.25))
df$t2m <- seq_len(nrow(df))
regrid(df, "t2m", resolution = 0.5)

varunayan documentation built on Oct. 30, 2026, 1:07 a.m.