Learn R Programming

MazamaLocationUtils (version 0.4.3)

table_filterByDistance: Return known locations near a target location

Description

Returns a tibble of the known locations from locationTbl that are within distanceThreshold meters of the target location specified by longitude and latitude.

Usage

table_filterByDistance(
  locationTbl = NULL,
  longitude = NULL,
  latitude = NULL,
  distanceThreshold = NULL,
  measure = c("geodesic", "haversine", "vincenty", "cheap")
)

Value

Tibble of known locations.

Arguments

locationTbl

Tibble of known locations.

longitude

Target longitude in decimal degrees E.

latitude

Target latitude in decimal degrees N.

distanceThreshold

Distance in meters.

measure

One of "haversine" "vincenty", "geodesic", or "cheap" specifying desired method of geodesic distance calculation.

Examples

Run this code
library(MazamaLocationUtils)

locationTbl <- get(data("wa_monitors_500"))

# Too small a distanceThreshold will not find a match
locationTbl %>%
  table_filterByDistance(
    longitude = -117.3647, 
    latitude = 47.6725, 
    distanceThreshold = 10
  ) %>% 
  dplyr::glimpse()

# Expanding the distanceThreshold will find several
locationTbl %>%
  table_filterByDistance(
    longitude = -117.3647, 
    latitude = 47.6725, 
    distanceThreshold = 10000
  ) %>%
  dplyr::glimpse()

Run the code above in your browser using DataLab