osmdata_sf | R Documentation |
Return an OSM Overpass query as an osmdata object in sf format.
osmdata_sf(q, doc, quiet = TRUE, stringsAsFactors = FALSE)
q |
An object of class |
doc |
If missing, |
quiet |
suppress status messages. |
stringsAsFactors |
Should character strings in 'sf' 'data.frame' be coerced to factors? |
An object of class osmdata
with the OSM components (points, lines,
and polygons) represented in sf format.
In 'dplyr'-type workflows in which the output of this function is piped to other functions, it will generally be necessary to explicitly load the sf package into the current workspace with 'library(sf)'.
Other extract:
osmdata_data_frame()
,
osmdata_sc()
,
osmdata_sp()
,
osmdata_xml()
## Not run:
query <- opq ("hampi india") |>
add_osm_feature (key = "historic", value = "ruins")
# Then extract data from 'Overpass' API
hampi_sf <- osmdata_sf (query)
## End(Not run)
# Complex query as a string (not possible with regular osmdata functions)
q <- '[out:xml][timeout:50];
area[name="Països Catalans"][boundary=political]->.boundaryarea;
rel(area.boundaryarea)[admin_level=8][boundary=administrative];
map_to_area -> .all_level_8_areas;
( nwr(area.boundaryarea)[amenity=townhall]; >; );
is_in;
area._[admin_level=8][boundary=administrative] -> .level_8_areas_with_townhall;
(.all_level_8_areas; - .level_8_areas_with_townhall;);
rel(pivot);
(._; >;);
out;'
## Not run:
no_townhall <- osmdata_sf (q)
no_townhall
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.