The secondary_weights()
function resamples a raster of interest to the
desired resolution and outputs a table of weights for use in the function
overlay_weights()
.
Arguments
- secondary_raster
a raster of a secondary variable, for example cropland coverage or population
- grid
a raster layer with the same spatial resolution as the climate data
- extent
an optional extent to crop the secondary_raster to for faster processing. Format must be compatible with raster::crop(). The default is "full", which resamples the whole secondary raster without cropping.
Examples
secondary_weights_output <- secondary_weights(
secondary_raster = cropland_nj_2015, # A raster of cropland to resample
# and convert to a data.table
grid = era5_grid, # The grid to resample the secondary_raster to (`era5_grid`
# is the default)
extent = "full" # The default, which resamples the whole secondary raster
# without cropping (`'full'` is the default)
)
#> Checking for raster alignment
#> Longitude coordinates do not match. Aligning longitudes to standard coordinates.
#> Resampling secondary_raster
#> Creating a table of weights
head(secondary_weights_output)
#> x y weight
#> <num> <num> <num>
#> 1: -76.25 41.75 0.2294976
#> 2: -76.00 41.75 0.2198315
#> 3: -75.75 41.75 0.1777267
#> 4: -75.50 41.75 0.1362904
#> 5: -75.25 41.75 0.1061073
#> 6: -75.00 41.75 0.1215708