View source: R/reverse_geo_lite_sf.R
| reverse_geo_lite_sf | R Documentation |
Generates an address from latitude and longitude (latitudes in
\left[-90, 90 \right] and longitudes in \left[-180, 180 \right]),
and returns the sf object associated with the query using
sf. See reverse_geo_lite() for retrieving the data in
tibble format.
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 |
Latitude values in numeric format. Must be in the range
|
long |
Longitude values in numeric format. Must be in the range
|
address |
Address column name in the output data (default |
full_results |
Return all available data from the Nominatim API.
If |
return_coords |
Return input coordinates with results if |
verbose |
If |
nominatim_server |
URL of the Nominatim server to use. Defaults to
|
progressbar |
Logical. If |
custom_query |
Named list with API-specific parameters, for example
|
points_only |
Logical |
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.
Use the option custom_query = list(zoom = 3) to adjust the output. Some
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 parameter points_only specifies whether the function results will be
points (all Nominatim results are guaranteed to have at least point
geometry) or other geometry types.
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.
This function is vectorized, allowing multiple addresses to be geocoded.
With points_only = FALSE, multiple geometry types may be returned.
Reverse geocoding:
reverse_geo_lite()
sf outputs:
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 polygon
col_sf <- reverse_geo_lite_sf(
lat = col_lat,
lon = 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,
lon = 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()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.