| 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 [cph] (For the data) |
| Maintainer: | Diego Hernangómez <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.6.0 |
| Built: | 2026-06-22 13:56:42 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
|
Individual bounding box coordinates. 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()
# 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") }# 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 string giving the name of the latitude column in the output.
Defaults to |
long |
A string giving the name of the longitude column in the output.
Defaults to |
full_results |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving 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 be passed to custom_query.
A tibble with the results that match the query.
Address search functions:
geo_address_lookup_sf(),
geo_amenity(),
geo_amenity_sf(),
geo_lite(),
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
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 |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
points_only |
If |
See https://nominatim.org/release-docs/latest/api/Lookup/ for additional
parameters to be passed 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_address_lookup(),
geo_amenity(),
geo_amenity_sf(),
geo_lite(),
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
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()
# Notre-Dame Cathedral, 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() } # Vectorized input several <- geo_address_lookup_sf(c(146656, 240109189), type = c("R", "N")) several# Notre-Dame Cathedral, 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() } # Vectorized input 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 bounding box (viewbox) used to limit the search. Supply a
numeric vector of longitude ( |
amenity |
A character vector of amenities to look up,
for example |
lat |
A string giving the name of the latitude column in the output.
Defaults to |
long |
A string giving the name of the longitude column in the output.
Defaults to |
limit |
A positive integer giving the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
progressbar |
If |
custom_query |
A named list of additional API parameters, for example
|
strict |
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 be passed to custom_query.
A tibble with the results that match the query.
Amenity lookup functions:
geo_amenity_sf(),
osm_amenities
Address search functions:
geo_address_lookup(),
geo_address_lookup_sf(),
geo_amenity_sf(),
geo_lite(),
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
# Times Square, NY, USA bbox <- c( -73.9894467311, 40.75573629, -73.9830630737, 40.75789245 ) geo_amenity( bbox = bbox, amenity = "restaurant" ) # 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 )# Times Square, NY, USA bbox <- c( -73.9894467311, 40.75573629, -73.9830630737, 40.75789245 ) geo_amenity( bbox = bbox, amenity = "restaurant" ) # 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 bounding box (viewbox) used to limit the search. Supply a
numeric vector of longitude ( |
amenity |
A character vector of amenities to look up,
for example |
limit |
A positive integer giving the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
progressbar |
If |
custom_query |
A named list of additional API parameters, for example
|
strict |
If |
points_only |
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 be passed 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
Address search functions:
geo_address_lookup(),
geo_address_lookup_sf(),
geo_amenity(),
geo_lite(),
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
Spatial output functions:
bbox_to_poly(),
geo_address_lookup_sf(),
geo_lite_sf(),
geo_lite_struct_sf(),
reverse_geo_lite_sf()
# Usera, Madrid library(ggplot2) mad <- geo_lite_sf("Usera, Madrid, Spain", points_only = FALSE) # 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)) }# Usera, Madrid library(ggplot2) mad <- geo_lite_sf("Usera, Madrid, Spain", points_only = FALSE) # 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 string giving the name of the latitude column in the output.
Defaults to |
long |
A string giving the name of the longitude column in the output.
Defaults to |
limit |
A positive integer giving the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
progressbar |
If |
custom_query |
A named list of additional API parameters, for example
|
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to be passed to custom_query.
A tibble with the results that match the query.
Address search functions:
geo_address_lookup(),
geo_address_lookup_sf(),
geo_amenity(),
geo_amenity_sf(),
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
geo_lite("Madrid, Spain") # 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") # 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 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 giving the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
return_addresses |
If |
full_results |
If |
verbose |
If |
progressbar |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
points_only |
If |
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to be passed 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_address_lookup(),
geo_address_lookup_sf(),
geo_amenity(),
geo_amenity_sf(),
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()
# 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") } # 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) }# 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") } # 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 string giving the name or type of amenity. See
|
street |
A string giving the house number and street name. |
city |
A string giving the city. |
county |
A string giving the county. |
state |
A string giving the state. |
country |
A string giving the country. |
postalcode |
A string giving the postal code. |
lat |
A string giving the name of the latitude column in the output.
Defaults to |
long |
A string giving the name of the longitude column in the output.
Defaults to |
limit |
A positive integer giving the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving 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 be passed to custom_query.
A tibble with the results that match the query.
Address search functions:
geo_address_lookup(),
geo_address_lookup_sf(),
geo_amenity(),
geo_amenity_sf(),
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 string giving the name or type of amenity. See
|
street |
A string giving the house number and street name. |
city |
A string giving the city. |
county |
A string giving the county. |
state |
A string giving the state. |
country |
A string giving the country. |
postalcode |
A string giving the postal code. |
limit |
A positive integer giving the maximum number of results to return per query. Nominatim returns at most 50 results per query. |
full_results |
If |
return_addresses |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
custom_query |
A named list of additional API parameters, for example
|
points_only |
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 be passed 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_address_lookup(),
geo_address_lookup_sf(),
geo_amenity(),
geo_amenity_sf(),
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()
# Structured address search pl_mayor <- geo_lite_struct_sf( street = "Plaza Mayor", county = "Comunidad de Madrid", country = "Spain", limit = 50, full_results = TRUE, verbose = TRUE ) # 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)) }# Structured address search pl_mayor <- geo_lite_struct_sf( street = "Plaza Mayor", county = "Comunidad de Madrid", country = "Spain", limit = 50, full_results = TRUE, verbose = TRUE ) # 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 136 rows and three columns:
The category of the amenity.
The value of the amenity.
A brief description of the type of amenity.
The data were extracted on April 3, 2024.
https://wiki.openstreetmap.org/wiki/Key:amenity
Amenity lookup functions:
geo_amenity(),
geo_amenity_sf()
data("osm_amenities") osm_amenitiesdata("osm_amenities") osm_amenities
Finds addresses from latitude and longitude coordinates and returns the
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 |
Numeric latitude values in the range
|
long |
Numeric longitude values in the range
|
address |
A string giving the name of the address column in the output.
Defaults to |
full_results |
If |
return_coords |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
progressbar |
If |
custom_query |
A named list of API-specific parameters, for example
|
See https://nominatim.org/release-docs/latest/api/Reverse/ for additional
parameters to be passed 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) # Multiple coordinate pairs reverse_geo_lite(lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375)) # Set the zoom to 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) # Multiple coordinate pairs reverse_geo_lite(lat = c(40.75728, 55.95335), long = c(-73.98586, -3.188375)) # Set the zoom to 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)
Finds addresses from latitude and longitude coordinates and returns the
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 |
Numeric latitude values in the range
|
long |
Numeric longitude values in the range
|
address |
A string giving the name of the address column in the output.
Defaults to |
full_results |
If |
return_coords |
If |
verbose |
If |
nominatim_server |
A string giving the base URL of the Nominatim
server. Defaults to
|
progressbar |
If |
custom_query |
A named list of API-specific parameters, for example
|
points_only |
If |
See https://nominatim.org/release-docs/latest/api/Reverse/ for additional
parameters to be passed 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) # Colosseum coordinates col_lon <- 12.49309 col_lat <- 41.89026 # 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() } # City of Rome: 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) # Colosseum coordinates col_lon <- 12.49309 col_lat <- 41.89026 # 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() } # City of Rome: 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() }