| fetch_osm | R Documentation |
A drop-in replacement for osmdata::osmdata_sf() that sidesteps
the Overpass server-status check osmdata performs before each
download.fetch_osm() builds the Overpass query
with osmdata's helpers, POSTs it directly with the curl
package, and then hands the raw response back to osmdata for
parsing.
fetch_osm(
bbox,
key = "highway",
value = NULL,
endpoint = "https://overpass-api.de/api/interpreter",
timeout = 180,
user_agent = "MetricGraph-R-package",
cache_path = NULL,
retries = 2,
...
)
bbox |
A bounding box, passed to |
key |
OSM key to filter on, e.g. |
value |
Optional character vector of values for |
endpoint |
Overpass endpoint URL, or a character vector of URLs
that are tried in order. Defaults to the main |
timeout |
Server-side query timeout in seconds. Forwarded to
both |
user_agent |
String sent as the |
cache_path |
Optional path. If provided and the file already exists, the download is skipped and the cached response is parsed instead. If provided and the file does not exist, the response is saved there for re-use. |
retries |
Number of times a request to each endpoint is retried after a transient failure (HTTP 429 or 5xx, or a connection error), with exponential backoff between attempts. |
... |
Forwarded to |
An osmdata list with elements $osm_points,
$osm_lines, $osm_polygons, $osm_multilines,
$osm_multipolygons (same structure as osmdata::osmdata_sf()).
Tags appear as columns of each sf data frame.
metric_graph_from_osm() which wraps this and returns a
ready-to-use metric_graph.
## Not run:
## All highway ways in a small bbox around San Jose.
osm <- fetch_osm(
bbox = c(-122.10, 37.22, -121.80, 37.45),
key = "highway",
value = c("motorway", "motorway_link", "primary", "secondary")
)
head(osm$osm_lines[, c("highway", "oneway", "geometry")])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.