geo_lite_sf | R Documentation |
This function allows you to geocode addresses and return the corresponding
spatial object. This function returns the sf spatial object
associated with the query, see geo_lite_sf()
for retrieving the data in
tibble format.
geo_lite_sf(
address,
limit = 1,
return_addresses = TRUE,
full_results = FALSE,
verbose = FALSE,
custom_query = list(),
points_only = TRUE
)
address |
character with single line address
( |
limit |
maximum number of results to return per input address. Note that each query returns a maximum of 50 results. |
return_addresses |
return input addresses with results if |
full_results |
returns all available data from the API service.
If |
verbose |
if |
custom_query |
A named list with API-specific parameters to be used
(i.e. |
points_only |
Logical |
See https://nominatim.org/release-docs/latest/api/Search/ for additional
parameters to be passed to custom_query
.
A sf
object with the results.
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.
Geocoding strings:
geo_address_lookup_sf()
,
geo_address_lookup()
,
geo_amenity_sf()
,
geo_amenity()
,
geo_lite()
Get spatial (sf
) objects:
bbox_to_poly()
,
geo_address_lookup_sf()
,
geo_amenity_sf()
,
reverse_geo_lite_sf()
# Map - Points
library(ggplot2)
string <- "Statue of Liberty, NY, USA"
sol <- geo_lite_sf(string)
if (any(!sf::st_is_empty(sol))) {
ggplot(sol) +
geom_sf()
}
sol_poly <- geo_lite_sf(string, points_only = FALSE)
if (any(!sf::st_is_empty(sol_poly))) {
ggplot(sol_poly) +
geom_sf() +
geom_sf(data = sol, color = "red")
}
# Several results
Madrid <- geo_lite_sf("Madrid",
limit = 2,
points_only = FALSE, full_results = TRUE
)
if (any(!sf::st_is_empty(Madrid))) {
ggplot(Madrid) +
geom_sf(fill = NA)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.