| Title: | Interface to the 'Nominatim' API |
|---|---|
| Description: | Provides a lightweight interface to the 'Nominatim' API <https://nominatim.org/release-docs/latest/>. It supports free-form and structured address searches, searches for addresses from coordinates, amenity lookup and address lookup by 'OpenStreetMap' object identifier. It returns results as 'tibble' data frames or 'sf' objects. |
| Authors: | Diego Hernangómez [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8457-4658>), Jindra Lacko [ctb, rev] (ORCID: <https://orcid.org/0000-0002-0375-5156>), Alex White [ctb], OpenStreetMap contributors [cph] (For the osm_amenities data) |
| Maintainer: | Diego Hernangómez <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.6.0.9000 |
| Built: | 2026-07-18 23:38:35 UTC |
| Source: | https://github.com/dieghernan/nominatimlite |
sfc POLYGON objectConverts bounding box coordinates to an sfc object with
POLYGON geometry.
bbox_to_poly(bbox = NA, xmin = NA, ymin = NA, xmax = NA, ymax = NA, crs = 4326)bbox_to_poly(bbox = NA, xmin = NA, ymin = NA, xmax = NA, ymax = NA, crs = 4326)
bbox |
A numeric vector of four bounding box coordinates in the form
|
xmin, ymin, xmax, ymax
|
A numeric value specifying an individual bounding
box coordinate. Use these arguments as an alternative to |
crs |
coordinate reference system, something suitable as input to st_crs |
Bounding boxes can be located using online tools such as https://boundingbox.klokantech.com/.
An sfc object with POLYGON geometry and the coordinate
reference system specified by crs.
sf::st_as_sfc() and sf::st_sfc().
Spatial output functions:
geo_address_lookup_sf(),
geo_amenity_sf(),
geo_lite_sf(),
geo_lite_struct_sf(),
reverse_geo_lite_sf()
# Convert the bounding box for Germany. bbox_GER <- c(5.86631529, 47.27011137, 15.04193189, 55.09916098) bbox_GER_sf <- bbox_to_poly(bbox_GER) library(ggplot2) ggplot(bbox_GER_sf) + geom_sf() # Extract the bounding box of an `sf` object. sfobj <- geo_lite_sf("seychelles", points_only = FALSE) sfobj # Require at least one non-empty object. if (!all(sf::st_is_empty(sfobj))) { bbox <- sf::st_bbox(sfobj) bbox bbox_sfobj <- bbox_to_poly(bbox) ggplot(bbox_sfobj) + geom_sf(fill = "lightblue", alpha = 0.5) + geom_sf(data = sfobj, fill = "wheat") }# Convert the bounding box for Germany. bbox_GER <- c(5.86631529, 47.27011137, 15.04193189, 55.09916098) bbox_GER_sf <- bbox_to_poly(bbox_GER) library(ggplot2) ggplot(bbox_GER_sf) + geom_sf() # Extract the bounding box of an `sf` object. sfobj <- geo_lite_sf("seychelles", points_only = FALSE) sfobj # Require at least one non-empty object. if (!all(sf::st_is_empty(sfobj))) { bbox <- sf::st_bbox(sfobj) bbox bbox_sfobj <- bbox_to_poly(bbox) ggplot(bbox_sfobj) + geom_sf(fill = "lightblue", alpha = 0.5) + geom_sf(data = sfobj, fill = "wheat") }
Looks up addresses and other details for one or more OpenStreetMap (OSM)
objects, such as nodes, ways or relations. Results are returned as a
tibble. Use geo_address_lookup_sf() to return an
sf object instead.
geo_address_lookup( osm_ids, type = c("N", "W", "R"), lat = "lat", long = "lon", full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list() )geo_address_lookup( osm_ids, type = c("N", "W", "R"), lat = "lat", long = "lon", full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list() )
osm_ids |
A numeric vector of OSM identifiers, for example
|
type |
A character vector containing the OSM object type associated
with each value in |
lat |
A character string specifying the name of the latitude column in
the output. Defaults to |
long |
A character string specifying the name of the longitude column
in the output. Defaults to |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
See https://nominatim.org/release-docs/latest/api/Lookup/ for additional
parameters to pass to custom_query.
A tibble with the results that match the query.
Address lookup functions:
geo_address_lookup_sf()
ids <- geo_address_lookup(osm_ids = c(46240148, 34633854), type = "W") ids several <- geo_address_lookup(c(146656, 240109189), type = c("R", "N")) severalids <- geo_address_lookup(osm_ids = c(46240148, 34633854), type = "W") ids several <- geo_address_lookup(c(146656, 240109189), type = c("R", "N")) several
Looks up addresses and other details for one or more OpenStreetMap (OSM)
objects, such as nodes, ways or relations. Results are returned as an
sf object. Use geo_address_lookup() to return a
tibble instead.
geo_address_lookup_sf( osm_ids, type = c("N", "W", "R"), full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list(), points_only = TRUE )geo_address_lookup_sf( osm_ids, type = c("N", "W", "R"), full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list(), points_only = TRUE )
osm_ids |
A numeric vector of OSM identifiers, for example
|
type |
A character vector containing the OSM object type associated
with each value in |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
points_only |
A logical value indicating whether to return only point
geometries. If |
See https://nominatim.org/release-docs/latest/api/Lookup/ for additional
parameters to pass to custom_query.
An sf object with the results that match the query.
The points_only argument controls whether the results contain only points.
All Nominatim results have at least a point geometry.
When points_only = FALSE, the geometry type depends on the matching
feature. Administrative areas and major buildings are returned as polygons,
rivers and roads are returned as lines and amenities may still be returned
as points.
This function is vectorized, allowing multiple addresses to be searched.
With points_only = FALSE, multiple geometry types may be returned.
Address lookup functions:
geo_address_lookup()
Spatial output functions:
bbox_to_poly(),
geo_amenity_sf(),
geo_lite_sf(),
geo_lite_struct_sf(),
reverse_geo_lite_sf()
# Look up Notre-Dame Cathedral in Paris. NotreDame <- geo_address_lookup_sf(osm_ids = 201611261, type = "W") # Require at least one non-empty object. if (!all(sf::st_is_empty(NotreDame))) { library(ggplot2) ggplot(NotreDame) + geom_sf() } NotreDame_poly <- geo_address_lookup_sf(201611261, type = "W", points_only = FALSE ) if (!all(sf::st_is_empty(NotreDame_poly))) { ggplot(NotreDame_poly) + geom_sf() } # Look up multiple OSM objects. several <- geo_address_lookup_sf(c(146656, 240109189), type = c("R", "N")) several# Look up Notre-Dame Cathedral in Paris. NotreDame <- geo_address_lookup_sf(osm_ids = 201611261, type = "W") # Require at least one non-empty object. if (!all(sf::st_is_empty(NotreDame))) { library(ggplot2) ggplot(NotreDame) + geom_sf() } NotreDame_poly <- geo_address_lookup_sf(201611261, type = "W", points_only = FALSE ) if (!all(sf::st_is_empty(NotreDame_poly))) { ggplot(NotreDame_poly) + geom_sf() } # Look up multiple OSM objects. several <- geo_address_lookup_sf(c(146656, 240109189), type = c("R", "N")) several
Looks up OpenStreetMap amenities within a bounding box of
the form (xmin, ymin, xmax, ymax). Results are returned as a
tibble. Use geo_amenity_sf() to return an
sf object instead.
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 )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 )
bbox |
A numeric vector, an |
amenity |
A character vector of amenities to look up,
for example |
lat |
A character string specifying the name of the latitude column in
the output. Defaults to |
long |
A character string specifying the name of the longitude column
in the output. Defaults to |
limit |
A positive integer specifying the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
progressbar |
A logical value indicating whether to display a progress bar when processing multiple queries. |
custom_query |
A named list of additional API parameters, for example
|
strict |
A logical value indicating whether to keep only results inside
|
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 pass to custom_query.
A tibble with the results that match the query.
Amenity lookup functions:
geo_amenity_sf(),
osm_amenities
# Define a bounding box around Times Square, New York. bbox <- c( -73.9894467311, 40.75573629, -73.9830630737, 40.75789245 ) geo_amenity( bbox = bbox, amenity = "restaurant" ) # Search for multiple 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 )# Define a bounding box around Times Square, New York. bbox <- c( -73.9894467311, 40.75573629, -73.9830630737, 40.75789245 ) geo_amenity( bbox = bbox, amenity = "restaurant" ) # Search for multiple 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 )
Looks up OpenStreetMap amenities within a bounding box of
the form (xmin, ymin, xmax, ymax). Results are returned as an
sf object. Use geo_amenity() to return a
tibble instead.
geo_amenity_sf( bbox, amenity, limit = 1, full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", progressbar = TRUE, custom_query = list(), strict = FALSE, points_only = TRUE )geo_amenity_sf( bbox, amenity, limit = 1, full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", progressbar = TRUE, custom_query = list(), strict = FALSE, points_only = TRUE )
bbox |
A numeric vector, an |
amenity |
A character vector of amenities to look up,
for example |
limit |
A positive integer specifying the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
progressbar |
A logical value indicating whether to display a progress bar when processing multiple queries. |
custom_query |
A named list of additional API parameters, for example
|
strict |
A logical value indicating whether to keep only results inside
|
points_only |
A logical value indicating whether to return only point
geometries. If |
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 pass to custom_query.
An sf object with the results that match the query.
The points_only argument controls whether the results contain only points.
All Nominatim results have at least a point geometry.
When points_only = FALSE, the geometry type depends on the matching
feature. Administrative areas and major buildings are returned as polygons,
rivers and roads are returned as lines and amenities may still be returned
as points.
This function is vectorized, allowing multiple addresses to be searched.
With points_only = FALSE, multiple geometry types may be returned.
Amenity lookup functions:
geo_amenity(),
osm_amenities
Spatial output functions:
bbox_to_poly(),
geo_address_lookup_sf(),
geo_lite_sf(),
geo_lite_struct_sf(),
reverse_geo_lite_sf()
# Retrieve the Usera district in Madrid. library(ggplot2) mad <- geo_lite_sf("Usera, Madrid, Spain", points_only = FALSE) # Search for restaurants, pubs and schools. rest_pub <- geo_amenity_sf(mad, c("restaurant", "pub", "school"), limit = 50 ) if (!all(sf::st_is_empty(rest_pub))) { ggplot(mad) + geom_sf() + geom_sf(data = rest_pub, aes(color = query, shape = query)) }# Retrieve the Usera district in Madrid. library(ggplot2) mad <- geo_lite_sf("Usera, Madrid, Spain", points_only = FALSE) # Search for restaurants, pubs and schools. rest_pub <- geo_amenity_sf(mad, c("restaurant", "pub", "school"), limit = 50 ) if (!all(sf::st_is_empty(rest_pub))) { ggplot(mad) + geom_sf() + geom_sf(data = rest_pub, aes(color = query, shape = query)) }
Searches for addresses supplied as a character vector and returns matching
results as a tibble. Use geo_lite_sf() to return an
sf object instead.
This function performs the free-form address search described in the API endpoint.
geo_lite( address, 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() )geo_lite( address, 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() )
address |
A character vector of single-line addresses, for example
|
lat |
A character string specifying the name of the latitude column in
the output. Defaults to |
long |
A character string specifying the name of the longitude column
in the output. Defaults to |
limit |
A positive integer specifying the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
progressbar |
A logical value indicating whether to display a progress bar when processing multiple queries. |
custom_query |
A named list of additional API parameters, for example
|
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to pass to custom_query.
A tibble with the results that match the query.
Address search functions:
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
geo_lite("Madrid, Spain") # Search for multiple addresses. geo_lite(c("Madrid", "Barcelona")) # Restrict the search to the United States and return all fields. geo_lite(c("Madrid", "Barcelona"), custom_query = list(countrycodes = "US"), full_results = TRUE )geo_lite("Madrid, Spain") # Search for multiple addresses. geo_lite(c("Madrid", "Barcelona")) # Restrict the search to the United States and return all fields. geo_lite(c("Madrid", "Barcelona"), custom_query = list(countrycodes = "US"), full_results = TRUE )
Searches for addresses supplied as a character vector and returns matching
results as an sf object. Use geo_lite() to return a
tibble instead.
This function performs the free-form address search described in the API endpoint.
geo_lite_sf( address, limit = 1, return_addresses = TRUE, full_results = FALSE, verbose = FALSE, progressbar = TRUE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list(), points_only = TRUE )geo_lite_sf( address, limit = 1, return_addresses = TRUE, full_results = FALSE, verbose = FALSE, progressbar = TRUE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list(), points_only = TRUE )
address |
A character vector of single-line addresses, for example
|
limit |
A positive integer specifying the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
verbose |
A logical value indicating whether to display detailed messages in the console. |
progressbar |
A logical value indicating whether to display a progress bar when processing multiple queries. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
points_only |
A logical value indicating whether to return only point
geometries. If |
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to pass to custom_query.
An sf object with the results that match the query.
The points_only argument controls whether the results contain only points.
All Nominatim results have at least a point geometry.
When points_only = FALSE, the geometry type depends on the matching
feature. Administrative areas and major buildings are returned as polygons,
rivers and roads are returned as lines and amenities may still be returned
as points.
This function is vectorized, allowing multiple addresses to be searched.
With points_only = FALSE, multiple geometry types may be returned.
Address search functions:
geo_lite(),
geo_lite_struct(),
geo_lite_struct_sf()
Spatial output functions:
bbox_to_poly(),
geo_address_lookup_sf(),
geo_amenity_sf(),
geo_lite_struct_sf(),
reverse_geo_lite_sf()
# Return point geometries. library(ggplot2) string <- "Statue of Liberty, NY, USA" sol <- geo_lite_sf(string) if (!all(sf::st_is_empty(sol))) { ggplot(sol) + geom_sf() } sol_poly <- geo_lite_sf(string, points_only = FALSE) if (!all(sf::st_is_empty(sol_poly))) { ggplot(sol_poly) + geom_sf() + geom_sf(data = sol, color = "red") } # Return multiple matches. madrid <- geo_lite_sf("Comunidad de Madrid, Spain", limit = 2, points_only = FALSE, full_results = TRUE ) if (!all(sf::st_is_empty(madrid))) { ggplot(madrid) + geom_sf(fill = NA) }# Return point geometries. library(ggplot2) string <- "Statue of Liberty, NY, USA" sol <- geo_lite_sf(string) if (!all(sf::st_is_empty(sol))) { ggplot(sol) + geom_sf() } sol_poly <- geo_lite_sf(string, points_only = FALSE) if (!all(sf::st_is_empty(sol_poly))) { ggplot(sol_poly) + geom_sf() + geom_sf(data = sol, color = "red") } # Return multiple matches. madrid <- geo_lite_sf("Comunidad de Madrid, Spain", limit = 2, points_only = FALSE, full_results = TRUE ) if (!all(sf::st_is_empty(madrid))) { ggplot(madrid) + geom_sf(fill = NA) }
Searches for addresses already split into components and returns matching
results as a tibble. Use geo_lite_struct_sf() to return
an sf object instead.
This function performs the structured address search described in the
API endpoint. To
perform a free-form search, use geo_lite().
geo_lite_struct( amenity = NULL, street = NULL, city = NULL, county = NULL, state = NULL, country = NULL, postalcode = NULL, lat = "lat", long = "lon", limit = 1, full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list() )geo_lite_struct( amenity = NULL, street = NULL, city = NULL, county = NULL, state = NULL, country = NULL, postalcode = NULL, lat = "lat", long = "lon", limit = 1, full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list() )
amenity |
A character string specifying the name or type of amenity. See
|
street |
A character string specifying the house number and street name. |
city |
A character string specifying the city. |
county |
A character string specifying the county. |
state |
A character string specifying the state. |
country |
A character string specifying the country. |
postalcode |
A character string specifying the postal code. |
lat |
A character string specifying the name of the latitude column in
the output. Defaults to |
long |
A character string specifying the name of the longitude column
in the output. Defaults to |
limit |
A positive integer specifying the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
A structured address search accepts an address already split into components. Each argument represents an address field. All components are optional, so provide only those relevant to the address you want to find.
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to pass to custom_query.
A tibble with the results that match the query.
Address search functions:
geo_lite(),
geo_lite_sf(),
geo_lite_struct_sf()
pl_mayor <- geo_lite_struct( street = "Plaza Mayor", country = "Spain", limit = 50, full_results = TRUE ) dplyr::glimpse(pl_mayor)pl_mayor <- geo_lite_struct( street = "Plaza Mayor", country = "Spain", limit = 50, full_results = TRUE ) dplyr::glimpse(pl_mayor)
Searches for addresses already split into components and returns matching
results as an sf object. Use geo_lite_struct() to return a
tibble instead.
This function performs the structured address search described in the
API endpoint. To
perform a free-form search, use geo_lite_sf().
geo_lite_struct_sf( amenity = NULL, street = NULL, city = NULL, county = NULL, state = NULL, country = NULL, postalcode = NULL, limit = 1, full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list(), points_only = TRUE )geo_lite_struct_sf( amenity = NULL, street = NULL, city = NULL, county = NULL, state = NULL, country = NULL, postalcode = NULL, limit = 1, full_results = FALSE, return_addresses = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", custom_query = list(), points_only = TRUE )
amenity |
A character string specifying the name or type of amenity. See
|
street |
A character string specifying the house number and street name. |
city |
A character string specifying the city. |
county |
A character string specifying the county. |
state |
A character string specifying the state. |
country |
A character string specifying the country. |
postalcode |
A character string specifying the postal code. |
limit |
A positive integer specifying the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_addresses |
A logical value indicating whether to include single-line addresses in the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
points_only |
A logical value indicating whether to return only point
geometries. If |
A structured address search accepts an address already split into components. Each argument represents an address field. All components are optional, so provide only those relevant to the address you want to find.
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to pass to custom_query.
An sf object with the results that match the query.
The points_only argument controls whether the results contain only points.
All Nominatim results have at least a point geometry.
When points_only = FALSE, the geometry type depends on the matching
feature. Administrative areas and major buildings are returned as polygons,
rivers and roads are returned as lines and amenities may still be returned
as points.
This function is vectorized, allowing multiple addresses to be searched.
With points_only = FALSE, multiple geometry types may be returned.
Address search functions:
geo_lite(),
geo_lite_sf(),
geo_lite_struct()
Spatial output functions:
bbox_to_poly(),
geo_address_lookup_sf(),
geo_amenity_sf(),
geo_lite_sf(),
reverse_geo_lite_sf()
# Search with a structured address. pl_mayor <- geo_lite_struct_sf( street = "Plaza Mayor", county = "Comunidad de Madrid", country = "Spain", limit = 50, full_results = TRUE, verbose = TRUE ) # Retrieve an administrative boundary. ccaa <- geo_lite_sf("Comunidad de Madrid, Spain", points_only = FALSE) library(ggplot2) if (any(!sf::st_is_empty(pl_mayor), !sf::st_is_empty(ccaa))) { ggplot(ccaa) + geom_sf() + geom_sf(data = pl_mayor, aes(shape = addresstype, color = addresstype)) }# Search with a structured address. pl_mayor <- geo_lite_struct_sf( street = "Plaza Mayor", county = "Comunidad de Madrid", country = "Spain", limit = 50, full_results = TRUE, verbose = TRUE ) # Retrieve an administrative boundary. ccaa <- geo_lite_sf("Comunidad de Madrid, Spain", points_only = FALSE) library(ggplot2) if (any(!sf::st_is_empty(pl_mayor), !sf::st_is_empty(ccaa))) { ggplot(ccaa) + geom_sf() + geom_sf(data = pl_mayor, aes(shape = addresstype, color = addresstype)) }
A dataset of amenity values available on OpenStreetMap.
A tibble with 140 rows and three columns:
Amenity category.
Amenity value.
Brief description of the amenity type.
The data were extracted on July 11, 2026. See
inst/COPYRIGHTS for copyright and license details.
https://wiki.openstreetmap.org/wiki/Key:amenity
Amenity lookup functions:
geo_amenity(),
geo_amenity_sf()
data("osm_amenities") osm_amenitiesdata("osm_amenities") osm_amenities
Reverse geocodes latitude and longitude coordinates and returns matching
results as a tibble. Latitude values must be in
and longitudes in
. Use reverse_geo_lite_sf() to return an
sf object instead.
reverse_geo_lite( lat, long, address = "address", full_results = FALSE, return_coords = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", progressbar = TRUE, custom_query = list() )reverse_geo_lite( lat, long, address = "address", full_results = FALSE, return_coords = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", progressbar = TRUE, custom_query = list() )
lat |
A numeric vector of latitude values in the range
|
long |
A numeric vector of longitude values in the range
|
address |
A character string specifying the name of the address column
in the output. Defaults to |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_coords |
A logical value indicating whether to return the input coordinates with the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
progressbar |
A logical value indicating whether to display a progress bar when processing multiple queries. |
custom_query |
A named list of API-specific parameters, for example
|
See https://nominatim.org/release-docs/latest/api/Reverse/ for additional
parameters to pass to custom_query.
A tibble with the results that match the query.
Set custom_query = list(zoom = 3) to adjust the output. Selected zoom
levels correspond to these address details:
| zoom | address_detail |
3 |
country |
5 |
state |
8 |
county |
10 |
city |
14 |
suburb |
16 |
major streets |
17 |
major and minor streets |
18 |
building |
Reverse geocoding functions:
reverse_geo_lite_sf()
reverse_geo_lite(lat = 40.75728, long = -73.98586) # Reverse geocode multiple coordinate pairs. reverse_geo_lite(lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375)) # Set the zoom to the country level. sev <- reverse_geo_lite( lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375), custom_query = list(zoom = 0, extratags = TRUE), verbose = TRUE, full_results = TRUE ) dplyr::glimpse(sev)reverse_geo_lite(lat = 40.75728, long = -73.98586) # Reverse geocode multiple coordinate pairs. reverse_geo_lite(lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375)) # Set the zoom to the country level. sev <- reverse_geo_lite( lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375), custom_query = list(zoom = 0, extratags = TRUE), verbose = TRUE, full_results = TRUE ) dplyr::glimpse(sev)
Reverse geocodes latitude and longitude coordinates and returns matching
results as an sf object. Latitude values must be in
and longitude values in
. Use reverse_geo_lite() to return a
tibble instead.
reverse_geo_lite_sf( lat, long, address = "address", full_results = FALSE, return_coords = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", progressbar = TRUE, custom_query = list(), points_only = TRUE )reverse_geo_lite_sf( lat, long, address = "address", full_results = FALSE, return_coords = TRUE, verbose = FALSE, nominatim_server = "https://nominatim.openstreetmap.org/", progressbar = TRUE, custom_query = list(), points_only = TRUE )
lat |
A numeric vector of latitude values in the range
|
long |
A numeric vector of longitude values in the range
|
address |
A character string specifying the name of the address column
in the output. Defaults to |
full_results |
A logical value indicating whether to return all
available fields from the Nominatim API. If |
return_coords |
A logical value indicating whether to return the input coordinates with the results. |
verbose |
A logical value indicating whether to display detailed messages in the console. |
nominatim_server |
A character string specifying the base URL of the
Nominatim server. Defaults to
|
progressbar |
A logical value indicating whether to display a progress bar when processing multiple queries. |
custom_query |
A named list of API-specific parameters, for example
|
points_only |
A logical value indicating whether to return only point
geometries. If |
See https://nominatim.org/release-docs/latest/api/Reverse/ for additional
parameters to pass to custom_query.
An sf object with the results that match the query.
Set custom_query = list(zoom = 3) to adjust the output. Selected zoom
levels correspond to these address details:
| zoom | address_detail |
3 |
country |
5 |
state |
8 |
county |
10 |
city |
14 |
suburb |
16 |
major streets |
17 |
major and minor streets |
18 |
building |
The points_only argument controls whether the results contain only points.
All Nominatim results have at least a point geometry.
When points_only = FALSE, the geometry type depends on the matching
feature. Administrative areas and major buildings are returned as polygons,
rivers and roads are returned as lines and amenities may still be returned
as points.
This function is vectorized, allowing multiple addresses to be searched.
With points_only = FALSE, multiple geometry types may be returned.
Reverse geocoding functions:
reverse_geo_lite()
Spatial output functions:
bbox_to_poly(),
geo_address_lookup_sf(),
geo_amenity_sf(),
geo_lite_sf(),
geo_lite_struct_sf()
library(ggplot2) # Define the Colosseum coordinates. col_lon <- 12.49309 col_lat <- 41.89026 # Return the Colosseum as a polygon. col_sf <- reverse_geo_lite_sf( lat = col_lat, long = col_lon, points_only = FALSE ) dplyr::glimpse(col_sf) if (!all(sf::st_is_empty(col_sf))) { ggplot(col_sf) + geom_sf() } # Return the city of Rome by using the same coordinates with zoom 10. rome_sf <- reverse_geo_lite_sf( lat = col_lat, long = col_lon, custom_query = list(zoom = 10), points_only = FALSE ) dplyr::glimpse(rome_sf) if (!all(sf::st_is_empty(rome_sf))) { ggplot(rome_sf) + geom_sf() }library(ggplot2) # Define the Colosseum coordinates. col_lon <- 12.49309 col_lat <- 41.89026 # Return the Colosseum as a polygon. col_sf <- reverse_geo_lite_sf( lat = col_lat, long = col_lon, points_only = FALSE ) dplyr::glimpse(col_sf) if (!all(sf::st_is_empty(col_sf))) { ggplot(col_sf) + geom_sf() } # Return the city of Rome by using the same coordinates with zoom 10. rome_sf <- reverse_geo_lite_sf( lat = col_lat, long = col_lon, custom_query = list(zoom = 10), points_only = FALSE ) dplyr::glimpse(rome_sf) if (!all(sf::st_is_empty(rome_sf))) { ggplot(rome_sf) + geom_sf() }