Incoming longitude and latitude values are compared against the incoming locationTbl to see if they are already within distanceThreshold meters of an existing entry. A new record is created for each location that is not already found in locationTbl.

table_addLocation(
  locationTbl = NULL,
  longitude = NULL,
  latitude = NULL,
  distanceThreshold = NULL,
  stateDataset = "NaturalEarthAdm1",
  elevationService = NULL,
  addressService = NULL,
  verbose = TRUE
)

Arguments

locationTbl

Tibble of known locations.

longitude

Vector of longitudes in decimal degrees E.

latitude

Vector of latitudes in decimal degrees N.

distanceThreshold

Distance in meters.

stateDataset

Name of spatial dataset to use for determining state codes, Default: 'NaturalEarthAdm1'

elevationService

Name of the elevation service to use for determining the elevation. Default: NULL skips this step. Accepted values: "usgs".

addressService

Name of the address service to use for determining the street address. Default: NULL skips this step. Accepted values: "photon".

verbose

Logical controlling the generation of progress messages.

Value

Updated tibble of known locations.

Note

This function is a vectorized version of table_addSingleLocation().

Examples

# \donttest{
library(MazamaLocationUtils)

# Fail gracefully if any resources are not available
try({

  # Set up standard directories and spatial data
  spatialDataDir <- tempdir() # typically "~/Data/Spatial"
  initializeMazamaSpatialUtils(spatialDataDir)

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

  # Coulee City, WA
  lon <- -119.290904
  lat <- 47.611942

  locationTbl <- 
    locationTbl %>%
    table_addLocation(lon, lat, distanceThreshold = 500)
  
  dplyr::glimpse(locationTbl)
  
}, silent = FALSE)
#> Working on -119.2909040, 47.6119420 ...
#> Rows: 79
#> Columns: 13
#> $ locationID   <chr> "c2913q48uk", "c28f8z9xq8", "c23hfxrdne", "c2k9v9bjcy", "…
#> $ locationName <chr> "us.wa_c2913q", "us.wa_c28f8z", "us.wa_c23hfx", "us.wa_c2…
#> $ longitude    <dbl> -122.2852, -122.6600, -122.2233, -117.1801, -119.0084, -1…
#> $ latitude     <dbl> 48.06534, 48.29440, 47.28140, 46.72450, 46.20010, 48.5200…
#> $ elevation    <dbl> 12.9, 18.8, 34.8, 768.7, 114.7, 6.1, 64.5, 240.5, 247.5, …
#> $ countryCode  <chr> "US", "US", "US", "US", "US", "US", "US", "US", "US", "US…
#> $ stateCode    <chr> "WA", "WA", "WA", "WA", "WA", "WA", "WA", "WA", "WA", "WA…
#> $ countyName   <chr> "Snohomish", "Island", "King", "Whitman", "Walla Walla", …
#> $ timezone     <chr> "America/Los_Angeles", "America/Los_Angeles", "America/Lo…
#> $ houseNumber  <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ street       <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ city         <chr> "Tulalip Bay", "Oak Harbor", "Auburn", "Pullman", "Burban…
#> $ postalCode   <chr> "98207", "98277", "98002", "99163", "99323", "98221", "98…
# }