For spatial data read into a data frame with longitude and latitude specified for each observation, this function aggregates data to a new set of longitude/ latitude combinations, i.e., to a new grid. This effectively takes the mean across all gridcells that have their mid-point within the coarse-resolution gridcell and without area-weighing of constituent (fine-resolution) gridcells.

regrid_df(df, res, lon_start, lon_end, lat_start, lat_end, varnam = NA)

Arguments

df

A data frame. Must have columns named 'lon' and 'lat'.

res

Resolution of the new grid in decimal degrees

lon_start

The left (west) margin of the first (western-most) gridcell along longitudes.

lon_end

The right (east) margin of the first (eastern-most) gridcell along longitudes.

lat_start

The lower (south) margin of the first (southern-most) gridcell along latitudes

lat_end

The upper (north) margin of the first (northern-most) gridcell along latitudes

varnam

A character string specifying the variable name in the data frame. When not specified, regrids all numeric variables.

Value

A data frame