Learn R Programming

nominatimlite (version 0.1.6)

geo_amenity: Geocode amenities

Description

This function search amenities as defined by OpenStreetMap on a restricted area defined by a bounding box in the form of (<min_latitude>, <min_longitude>, <max_latitude>, <max_longitude>).

Usage

geo_amenity(
  bbox,
  amenity,
  lat = "lat",
  long = "lon",
  limit = 1,
  full_results = FALSE,
  return_addresses = TRUE,
  verbose = FALSE,
  custom_query = list(),
  strict = FALSE
)

Arguments

bbox

A numeric vector of latitude and longitude (<min_latitude>, <min_longitude>, <max_latitude>, <max_longitude>) that restrict the search area. See Details.

amenity

A character of a vector of character with the amenities to be geolocated (i.e. c("pub", "restaurant")). See Details or osm_amenities.

lat

latitude column name (i.e. "lat").

long

longitude column name (i.e. "long").

limit

maximum number of results to return per input address. Note that each query returns a maximum of 50 results.

full_results

returns all available data from the geocoding service if TRUE. If FALSE (default) then only latitude and longitude columns are returned from the geocoding service.

return_addresses

return input addresses with results if TRUE. Note that most services return the input addresses with full_results = TRUE and setting return_addresses to FALSE does not prevent this.

verbose

if TRUE then detailed logs are output to the console. FALSE is default. Can be set permanently with options(tidygeocoder.verbose = TRUE)

custom_query

API-specific parameters to be used. See geo_lite().

strict

Logical TRUE/FALSE. Force the results to be included inside the bbox. Note that Nominatim default behaviour may return results located outside the provided bounding box.

Value

A tibble with the results.

Details

Bounding boxes can be located using different online tools, as Bounding Box Tool.

For a full list of valid amenities see https://wiki.openstreetmap.org/wiki/Key:amenity.

See Also

Other amenity: bbox_to_poly(), geo_amenity_sf(), osm_amenities

Other geocoding: geo_address_lookup(), geo_lite(), reverse_geo_lite()

Examples

Run this code
# NOT RUN {
# Times Square, NY, USA
bbox <- c(
  -73.9894467311, 40.75573629,
  -73.9830630737, 40.75789245
)

geo_amenity(
  bbox = bbox,
  amenity = "restaurant"
)

# Several amenities
geo_amenity(
  bbox = bbox,
  amenity = c("restaurant", "pub")
)

# Increase limit and use with strict
geo_amenity(
  bbox = bbox,
  amenity = c("restaurant", "pub"),
  limit = 10,
  strict = TRUE
)
# }

Run the code above in your browser using DataLab