
Extract raster values at sites
geo_extract.RdJoins CHELSA, WorldClim or SRTM-style rasters (a terra::SpatRaster or
a file path) to site coordinates. Layer names become columns. Points that
fall on NA cells keep NA in those columns.
Arguments
- data
A data frame or
sfobject with site coordinates.- raster
A
terra::SpatRaster, a file path, or a list of either.- lon, lat
<
data-masking> Coordinate columns whendatais notsf.- method
Extraction method passed to
terra::extract(), default"simple".- bind
Bind extracted columns onto
data? IfFALSE, return only the extracted tibble.
Examples
r <- terra::rast(ncols = 36, nrows = 18, xmin = -180, xmax = 180,
ymin = -90, ymax = 90, crs = "EPSG:4326")
terra::values(r) <- seq_len(terra::ncell(r))
names(r) <- "demo"
sites <- tibble::tibble(site = "a", lon = 147, lat = -9)
geo_extract(sites, r, lon, lat)
#> # A tibble: 1 × 4
#> site lon lat demo
#> <chr> <dbl> <dbl> <int>
#> 1 a 147 -9 357