R/extract_area.R
extract_area.Rd
A generic function to extract an area of interest for user-provided GPS coordinates.
extract_area(x, spatial, area)
List
. An object with names containing vector
pairings of
longitude and latitude values expressed as decimal degree values in that
order, each individual vectors
' items should be named "x" (longitude) and
"y" (latitude), respectively. The list
item names should be descriptive
of the individual vectors
and will be included in a "location" column of
the output.
a user-supplied sf object that contains information to derive location information from.
the field in spatial
that should be returned.
A data.table::data.table with the provided GPS
coordinates and the respective area
value from spatial
.
# load the `aez` data included in the package for use in example only.
# the `extract_ae_zone()` performs this exact task, this is strictly
# for demonstration purposes only
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
aez <- read_sf(system.file(
"extdata",
"aez.gpkg",
package = "extractOz",
mustWork = TRUE
))
locs <- list(
"Merredin" = c(x = 118.28, y = -31.48),
"Corrigin" = c(x = 117.87, y = -32.33),
"Tamworth" = c(x = 150.84, y = -31.07)
)
extract_area(x = locs, spatial = aez, area = "AEZ")
#> location x y AEZ
#> 1: Corrigin 117.87 -32.33 WA Central
#> 2: Merredin 118.28 -31.48 WA Eastern
#> 3: Tamworth 150.84 -31.07 NSW NE/Qld SE