geo_amenity: Geocode amenities

View source: R/geo_amenity.R

geo_amenityR Documentation

Geocode amenities

Description

Searches amenities as defined by OpenStreetMap in a restricted area defined by a bounding box in the form ⁠(<xmin>, <ymin>, <xmax>, <ymax>)⁠ and returns the tibble associated with the query. See geo_amenity_sf() for retrieving the data as an sf object.

Usage

geo_amenity(
  bbox,
  amenity,
  lat = "lat",
  long = "lon",
  limit = 1,
  full_results = FALSE,
  return_addresses = TRUE,
  verbose = FALSE,
  nominatim_server = "https://nominatim.openstreetmap.org/",
  progressbar = TRUE,
  custom_query = list(),
  strict = FALSE
)

Arguments

bbox

The bounding box (viewbox) used to limit the search. It can be a numeric vector of longitude (x) and latitude (y) in the form ⁠(xmin, ymin, xmax, ymax)⁠, or a sf or sfc object. See Details.

amenity

character value or vector with the amenities to geocode, for example c("pub", "restaurant"). See osm_amenities.

lat

Latitude column name in the output data (default "lat").

long

Longitude column name in the output data (default "long").

limit

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

full_results

Return all available data from the Nominatim API. If FALSE (default), only latitude, longitude and address columns are returned. See also return_addresses.

return_addresses

Return input addresses with results if TRUE.

verbose

If TRUE, detailed logs are output to the console.

nominatim_server

URL of the Nominatim server to use. Defaults to "https://nominatim.openstreetmap.org/".

progressbar

Logical. If TRUE displays a progress bar to indicate the progress of the function.

custom_query

Named list with API-specific parameters, for example list(countrycodes = "US"). See Details.

strict

Logical TRUE/FALSE. Force the results to be included inside the bbox. Nominatim's default behavior may return results located outside the provided bounding box.

Details

Bounding boxes can be located using online tools such as https://boundingbox.klokantech.com/.

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

See https://nominatim.org/release-docs/latest/api/Search/ for additional parameters to be passed to custom_query.

Value

A tibble with the results that match the query.

See Also

Amenity lookup: geo_amenity_sf(), osm_amenities

Geocoding: geo_address_lookup(), geo_address_lookup_sf(), geo_amenity_sf(), geo_lite(), geo_lite_sf(), geo_lite_struct(), geo_lite_struct_sf()

Examples



# 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 strict filtering
geo_amenity(
  bbox = bbox,
  amenity = c("restaurant", "pub"),
  limit = 10,
  strict = TRUE
)



nominatimlite documentation built on June 3, 2026, 9:06 a.m.