Skip to contents

A generic function to extract an area of interest for user-provided GPS coordinates.

Usage

extract_area(x, spatial, area)

Arguments

x

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.

spatial

a user-supplied sf::sf() object that contains information to derive location information from.

area

the field in spatial that should be returned.

Value

A data.table::data.table with the provided GPS coordinates and the respective area value from spatial.

Examples

# 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.10.2, GDAL 3.4.1, PROJ 8.2.1; 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")
#> Key: <location>
#>    location      x      y           AEZ
#>      <char>  <num>  <num>        <char>
#> 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