R package for downloading OpenStreetMap data
at main 72 lines 2.2 kB view raw
1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/get-osmdata-xml.R 3\name{osmdata_xml} 4\alias{osmdata_xml} 5\title{Return an OSM Overpass query in XML format 6Read an (XML format) OSM Overpass response from a string, a connection, 7or a raw vector.} 8\usage{ 9osmdata_xml(q, filename, quiet = TRUE, encoding) 10} 11\arguments{ 12\item{q}{An object of class \code{overpass_query} constructed with 13\link{opq} and \link{add_osm_feature} or a string with a valid query, such 14as \code{"(node(39.4712701,-0.3841326,39.4713799,-0.3839475);); out;"}. See examples below.} 15 16\item{filename}{If given, OSM data are saved to the named file} 17 18\item{quiet}{suppress status messages.} 19 20\item{encoding}{Unless otherwise specified XML documents are assumed to be 21encoded as UTF-8 or UTF-16. If the document is not UTF-8/16, and lacks 22an explicit encoding directive, this allows you to supply a default.} 23} 24\value{ 25An object of class \code{xml2::xml_document} containing the result of the 26overpass API query. 27} 28\description{ 29Return an OSM Overpass query in XML format 30Read an (XML format) OSM Overpass response from a string, a connection, 31or a raw vector. 32} 33\note{ 34Objects of class \code{xml_document} can be saved as \code{.xml} or 35\code{.osm} files with \code{xml2::write_xml}. 36} 37\examples{ 38\dontrun{ 39query <- opq ("hampi india") |> 40 add_osm_feature (key = "historic", value = "ruins") 41# Then extract data from 'Overpass' API and save to local file: 42osmdata_xml (query, filename = "hampi.osm") 43} 44 45# Complex query as a string (not possible with regular osmdata functions) 46q <- '[out:xml][timeout:50]; 47 area[name="Països Catalans"][boundary=political]->.boundaryarea; 48 49 rel(area.boundaryarea)[admin_level=8][boundary=administrative]; 50 map_to_area -> .all_level_8_areas; 51 52 ( nwr(area.boundaryarea)[amenity=townhall]; >; ); 53 is_in; 54 area._[admin_level=8][boundary=administrative] -> .level_8_areas_with_townhall; 55 56 (.all_level_8_areas; - .level_8_areas_with_townhall;); 57 rel(pivot); 58 out tags;' 59 60\dontrun{ 61no_townhall <- osmdata_xml (q) 62no_townhall 63} 64} 65\seealso{ 66Other extract: 67\code{\link{osmdata_data_frame}()}, 68\code{\link{osmdata_sc}()}, 69\code{\link{osmdata_sf}()}, 70\code{\link{osmdata_sp}()} 71} 72\concept{extract}