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)
A data frame. Must have columns named 'lon'
and 'lat'
.
Resolution of the new grid in decimal degrees
The left (west) margin of the first (western-most) gridcell along longitudes.
The right (east) margin of the first (eastern-most) gridcell along longitudes.
The lower (south) margin of the first (southern-most) gridcell along latitudes
The upper (north) margin of the first (northern-most) gridcell along latitudes
A character string specifying the variable name in the data frame. When not specified, regrids all numeric variables.
A data frame