View source: R/reverse_geo_lite_sf.R
reverse_geo_lite_sf | R Documentation |
Generates an address from a latitude and longitude. Latitudes must be
between [-90, 90]
and longitudes between [-180, 180]
. This function
returns the sf spatial object associated with the query, 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,
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 |
returns all available data from the API service.
If |
return_coords |
return input coordinates with results if |
verbose |
if |
custom_query |
API-specific parameters to be used, passed as a named
list (ie. |
points_only |
Logical |
See https://nominatim.org/release-docs/develop/api/Reverse/ for additional
parameters to be passed to custom_query
.
A sf
object with the results.
Use the option custom_query = list(zoom = 3)
to adjust the output. Some
equivalences on terms of zoom:
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 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.
reverse_geo_lite()
Reverse geocoding coordinates:
reverse_geo_lite()
Get spatial (sf
) objects:
bbox_to_poly()
,
geo_address_lookup_sf()
,
geo_amenity_sf()
,
geo_lite_sf()
library(ggplot2)
# Coliseum coords
col_lon <- 12.49309
col_lat <- 41.89026
# Coliseum as polygon
col_sf <- reverse_geo_lite_sf(
lat = col_lat,
lon = col_lon,
points_only = FALSE
)
dplyr::glimpse(col_sf)
if (any(!sf::st_is_empty(col_sf))) {
ggplot(col_sf) +
geom_sf()
}
# City of Rome - same coords 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 (any(!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.