The lookup API queries the address and other details of one or more
OSM objects (node, way, relation) and returns the spatial object
associated with the query using sf. See
geo_address_lookup() for retrieving the data in tibble
format.
Arguments
- osm_ids
Vector of OSM identifiers as numeric values. (
c(00000, 11111, 22222)).- type
Character vector of the OSM object type associated with each
osm_idsvalue. Possible values are node ("N"), way ("W") or relation ("R"). If a single value is provided, it will be recycled.- full_results
Returns all available data from the API service. If
FALSE(default), only address columns are returned. See alsoreturn_addresses.- return_addresses
Return input addresses with results if
TRUE.- verbose
If
TRUE, detailed logs are output to the console.- nominatim_server
The URL of the Nominatim server to use. Defaults to
"https://nominatim.openstreetmap.org/".- custom_query
A named list with API-specific parameters to be used, for example
list(countrycodes = "US"). See Details.- points_only
Logical
TRUE/FALSE. Whether to return only spatial points (TRUE, which is the default) or potentially other shapes as returned by the Nominatim API (FALSE). See About geometry types.
Value
A sf object with the results.
Details
See https://nominatim.org/release-docs/latest/api/Lookup/ 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 when points_only = FALSE, the type of geometry returned depends
on the object being geocoded. Administrative areas, major buildings and the
like will be returned as polygons, rivers, roads and similar features will
be returned as lines, and amenities may still be returned as points.
The function is vectorized, allowing multiple addresses to be geocoded,
with points_only = FALSE, multiple geometry types may be returned.
See also
Address Lookup API:
geo_address_lookup()
Geocoding:
geo_address_lookup(),
geo_amenity(),
geo_amenity_sf(),
geo_lite(),
geo_lite_sf(),
geo_lite_struct(),
geo_lite_struct_sf()
Get sf objects:
bbox_to_poly(),
geo_amenity_sf(),
geo_lite_sf(),
geo_lite_struct_sf(),
reverse_geo_lite_sf()
Examples
# \donttest{
# Notre Dame Cathedral, Paris
NotreDame <- geo_address_lookup_sf(osm_ids = 201611261, type = "W")
# Need 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
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -2.232455 ymin: 52.51739 xmax: 13.39513 ymax: 53.44246
#> Geodetic CRS: WGS 84
#> # A tibble: 2 × 3
#> query address geometry
#> * <chr> <chr> <POINT [°]>
#> 1 R146656 Manchester, Greater Manchester, England,… (-2.232455 53.44246)
#> 2 N240109189 Berlin, Deutschland (13.39513 52.51739)
# }
