Skip to contents

This function allows you to geocode addresses and return the corresponding spatial object. This function returns the spatial object associated with the query using sf, see geo_lite_sf() for retrieving the data in tibble format.


  limit = 1,
  return_addresses = TRUE,
  full_results = FALSE,
  verbose = FALSE,
  progressbar = TRUE,
  custom_query = list(),
  points_only = TRUE



character with single line address, e.g. ("1600 Pennsylvania Ave NW, Washington") or a vector of addresses (c("Madrid", "Barcelona")).


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


return input addresses with results if TRUE.


returns all available data from the API service. If FALSE (default) only address columns are returned. See also return_addresses.


if TRUE then detailed logs are output to the console.


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


A named list with API-specific parameters to be used (i.e. list(countrycodes = "US")). See Details.


Logical TRUE/FALSE. Whether to return only spatial points (TRUE, which is the default) or potentially other shapes as provided by the Nominatim API (FALSE). See About Geometry Types.


A sf object with the results.


See for additional parameters to be passed to custom_query.

About Geometry Types

The parameter points_only specifies whether the function results will be points (all Nominatim results are guaranteed to have at least point geometry) or possibly other spatial objects.

Note that the type of geometry returned in case of points_only = FALSE will depend on the object being geocoded:

  • Administrative areas, major buildings and the like will be returned as polygons.

  • Rivers, roads and their like as lines.

  • Amenities may be points even in case of a points_only = FALSE call.

The function is vectorized, allowing for multiple addresses to be geocoded; in case of points_only = FALSE multiple geometry types may be returned.


# \donttest{
# Map - Points

string <- "Statue of Liberty, NY, USA"
sol <- geo_lite_sf(string)

if (any(!sf::st_is_empty(sol))) {
  ggplot(sol) +

sol_poly <- geo_lite_sf(string, points_only = FALSE)

if (any(!sf::st_is_empty(sol_poly))) {
  ggplot(sol_poly) +
    geom_sf() +
    geom_sf(data = sol, color = "red")

# Several results

Madrid <- geo_lite_sf("Madrid",
  limit = 2,
  points_only = FALSE, full_results = TRUE

if (any(!sf::st_is_empty(Madrid))) {
  ggplot(Madrid) +
    geom_sf(fill = NA)

# }