View source: R/geo_amenity_sf.R
geo_amenity_sf | R Documentation |
This function search amenities as defined by OpenStreetMap
on a restricted area defined by a bounding box in the form
(<xmin>, <ymin>, <xmax>, <ymax>)
. This function returns the spatial
object associated with the query using sf, see geo_amenity()
for
retrieving the data in tibble
format.
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 |
The bounding box (viewbox) used to limit the search. It could be:
|
amenity |
A |
limit |
Maximum number of results to return per input address. Note that each query returns a maximum of 50 results. |
full_results |
Returns all available data from the API service.
If |
return_addresses |
Return input addresses with results if |
verbose |
If |
nominatim_server |
The URL of the Nominatim server to use.
Defaults to |
progressbar |
Logical. If |
custom_query |
A named list with API-specific parameters to be used
(i.e. |
strict |
Logical |
points_only |
Logical |
Bounding boxes can be located using different online tools, as Bounding Box Tool.
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 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.
Other amenity:
geo_amenity()
,
osm_amenities
Geocoding:
geo_address_lookup()
,
geo_address_lookup_sf()
,
geo_amenity()
,
geo_lite()
,
geo_lite_sf()
,
geo_lite_struct()
,
geo_lite_struct_sf()
Get sf
objects:
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 (any(!sf::st_is_empty(rest_pub))) {
ggplot(mad) +
geom_sf() +
geom_sf(data = rest_pub, aes(color = query, shape = query))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.