osmdata_data_frame | R Documentation |
Return an OSM Overpass query as a data.frame object.
osmdata_data_frame(q, doc, quiet = TRUE, stringsAsFactors = FALSE)
q |
An object of class |
doc |
If missing, |
quiet |
suppress status messages. |
stringsAsFactors |
Should character strings in the 'data.frame' be coerced to factors? |
If you are not interested in the geometries of the results, it's a
good option to query for objects that match the features only and forget
about members of the ways and relations. You can achieve this by passing
the parameter body = "tags"
to opq
.
A data.frame
with id, type and tags of the the objects from the
query.
Other extract:
osmdata_sc()
,
osmdata_sf()
,
osmdata_sp()
,
osmdata_xml()
## Not run:
query <- opq ("hampi india") |>
add_osm_feature (key = "historic", value = "ruins")
# Then extract data from 'Overpass' API
hampi_df <- osmdata_data_frame (query)
attr (hampi_df, "bbox")
attr (hampi_df, "overpass_call")
attr (hampi_df, "meta")
## End(Not run)
# Complex query as a string (not possible with regular osmdata functions)
q <- '[out:csv(::type, ::id, "name:ca", "wikidata")][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 tags;'
## Not run:
no_townhall <- osmdata_data_frame (q)
no_townhall
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.