Learn R Programming

MazamaLocationUtils (version 0.2.0)

table_findAdjacentLocations: Finds adjacent locations in a known locations table.

Description

Calculates distances between all locations within a known locations table and returns a tibble with the row indices and separation distances of those records separated by less than distanceThreshold meters.

It is useful when working with new metadata tables to identify ajacent locations early on so that decisions can be made about the appropriateness of the specified distanceThreshold.

Usage

table_findAdjacentLocations(
  locationTbl = NULL,
  distanceThreshold = NULL,
  measure = "geodesic"
)

Arguments

locationTbl

Tibble of known locations.

distanceThreshold

Distance in meters.

measure

One of "haversine" "vincenty", "geodesic", or "cheap" specifying desired method of geodesic distance calculation. See ?geodist::geodist.

Value

Tibble of known locations separated by less than distanceThreshold meters.

Examples

Run this code
# NOT RUN {
library(MazamaLocationUtils)

meta <- wa_airfire_meta

# Any locations closer than 2 km?
meta %>%
  table_findAdjacentLocations(distanceThreshold = 2000) %>%
  dplyr::select(monitorID, siteName, timezone)

# How about 4 km?
meta %>%
  table_findAdjacentLocations(distanceThreshold = 4000) %>%
  dplyr::select(monitorID, siteName, timezone)

# }

Run the code above in your browser using DataLab