View source: R/geo_lite_struct_sf.R
geo_lite_struct_sf | R Documentation |
Geocodes addresses already split into components and return the corresponding
spatial object. This function returns the spatial object associated with the
query using sf, see geo_lite_struct()
for retrieving the data in
tibble
format.
This function correspond to the structured query search described in the
API endpoint. For
performing a free-form search use geo_lite_sf()
.
geo_lite_struct_sf(
amenity = NULL,
street = NULL,
city = NULL,
county = NULL,
state = NULL,
country = NULL,
postalcode = NULL,
limit = 1,
full_results = FALSE,
return_addresses = TRUE,
verbose = FALSE,
nominatim_server = "https://nominatim.openstreetmap.org/",
custom_query = list(),
points_only = TRUE
)
amenity |
Name and/or type of POI, see also geo_amenity. |
street |
House number and street name. |
city |
City. |
county |
County. |
state |
State. |
country |
Country. |
postalcode |
Postal Code. |
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 |
custom_query |
A named list with API-specific parameters to be used
(i.e. |
points_only |
Logical |
The structured form of the search query allows to look up up an address that is already split into its components. Each parameter represents a field of the address. All parameters are optional. You should only use the ones that are relevant for the address you want to geocode.
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.
geo_lite_struct()
.
Geocoding:
geo_address_lookup()
,
geo_address_lookup_sf()
,
geo_amenity()
,
geo_amenity_sf()
,
geo_lite()
,
geo_lite_sf()
,
geo_lite_struct()
Get sf
objects:
bbox_to_poly()
,
geo_address_lookup_sf()
,
geo_amenity_sf()
,
geo_lite_sf()
,
reverse_geo_lite_sf()
# Map
pl_mayor <- geo_lite_struct_sf(
street = "Plaza Mayor",
county = "Comunidad de Madrid",
country = "Spain", limit = 50,
full_results = TRUE, verbose = TRUE
)
# Outline
ccaa <- geo_lite_sf("Comunidad de Madrid, Spain", points_only = FALSE)
library(ggplot2)
if (any(!sf::st_is_empty(pl_mayor), !sf::st_is_empty(ccaa))) {
ggplot(ccaa) +
geom_sf() +
geom_sf(data = pl_mayor, aes(shape = addresstype, color = addresstype))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.