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.

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.

Note

The measure "cheap" may be used to speed things up depending on the spatial scale being considered. Distances calculated with measure = "cheap" will vary by a few meters compared with those calculated using measure = "geodesic".

Examples

library(MazamaLocationUtils) meta <- wa_airfire_meta # Any locations closer than 2 km? meta %>% table_findAdjacentLocations(distanceThreshold = 2000) %>% dplyr::select(monitorID, siteName, timezone)
#> monitorID siteName #> lon_.122.671_lat_47.029_usfs.1078 lon_.122.671_lat_47.029_usfs.1078 #> lon_.122.677_lat_47.028_usfs.1078 lon_.122.677_lat_47.028_usfs.1078 #> timezone #> lon_.122.671_lat_47.029_usfs.1078 America/Los_Angeles #> lon_.122.677_lat_47.028_usfs.1078 America/Los_Angeles
# How about 4 km? meta %>% table_findAdjacentLocations(distanceThreshold = 4000) %>% dplyr::select(monitorID, siteName, timezone)
#> monitorID #> lon_.122.671_lat_47.029_usfs.1078 lon_.122.671_lat_47.029_usfs.1078 #> 530330057_01 530330057_01 #> 530330080_01 530330080_01 #> 530330057_01.1 530330057_01 #> lon_.122.677_lat_47.028_usfs.1078 lon_.122.677_lat_47.028_usfs.1078 #> 530330080_01.1 530330080_01 #> 530330030_01 530330030_01 #> 530331011_01 530331011_01 #> siteName timezone #> lon_.122.671_lat_47.029_usfs.1078 America/Los_Angeles #> 530330057_01 Seattle-Duwamish America/Los_Angeles #> 530330080_01 Seattle-Beacon Hill America/Los_Angeles #> 530330057_01.1 Seattle-Duwamish America/Los_Angeles #> lon_.122.677_lat_47.028_usfs.1078 America/Los_Angeles #> 530330080_01.1 Seattle-Beacon Hill America/Los_Angeles #> 530330030_01 Seattle-10th & Weller America/Los_Angeles #> 530331011_01 Seattle-South Park America/Los_Angeles