R/table_filterByDistance.R
table_filterByDistance.Rd
Returns a tibble of the known locations from locationTbl
that are within distanceThreshold
meters of the target location
specified by longitude
and latitude
.
table_filterByDistance(
locationTbl = NULL,
longitude = NULL,
latitude = NULL,
distanceThreshold = NULL,
measure = c("geodesic", "haversine", "vincenty", "cheap")
)
Tibble of known locations.
Target longitude in decimal degrees E.
Target latitude in decimal degrees N.
Distance in meters.
One of "haversine" "vincenty", "geodesic", or "cheap" specifying desired method of geodesic distance calculation.
Tibble of known locations.
Only a single target location is allowed.
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()
#> Rows: 0
#> Columns: 13
#> $ locationID <chr>
#> $ locationName <chr>
#> $ longitude <dbl>
#> $ latitude <dbl>
#> $ elevation <dbl>
#> $ countryCode <chr>
#> $ stateCode <chr>
#> $ countyName <chr>
#> $ timezone <chr>
#> $ houseNumber <chr>
#> $ street <chr>
#> $ city <chr>
#> $ postalCode <chr>
# Expanding the distanceThreshold will find several
locationTbl %>%
table_filterByDistance(
longitude = -117.3647,
latitude = 47.6725,
distanceThreshold = 10000
) %>%
dplyr::glimpse()
#> Rows: 3
#> Columns: 13
#> $ locationID <chr> "c2kx1q92rw", "c2kx5szwdw", "c2krrgkybu"
#> $ locationName <chr> "us.wa_c2kx1q", "us.wa_c2kx5s", "us.wa_c2krrg"
#> $ longitude <dbl> -117.3649, -117.2576, -117.4263
#> $ latitude <dbl> 47.67250, 47.66396, 47.69970
#> $ elevation <dbl> 586.2, 614.1, 624.9
#> $ countryCode <chr> "US", "US", "US"
#> $ stateCode <chr> "WA", "WA", "WA"
#> $ countyName <chr> "Spokane", "Spokane", "Spokane"
#> $ timezone <chr> "America/Los_Angeles", "America/Los_Angeles", "America/Lo…
#> $ houseNumber <chr> NA, NA, NA
#> $ street <chr> NA, NA, NA
#> $ city <chr> "Spokane", "Spokane Valley", "Spokane"
#> $ postalCode <chr> "99207", "99206", "99205"