Learn R Programming

mapsapi (version 0.1.0)

extract_segments: Extract *route segments* from a Google Maps Directions API response

Description

Extract *route segments* from a Google Maps Directions API response

Usage

extract_segments(doc)

Arguments

doc

XML document with Google Maps Directions API response

Value

Line layer (class sf) representing route segments

Examples

Run this code
# NOT RUN {
library(xml2)
doc = as_xml_document(response_directions)
seg = extract_segments(doc)
plot(seg)
# }
# NOT RUN {
doc = google_directions(
  origin = c(34.81127, 31.89277),
  destination = c(34.781107, 32.085003),
  alternatives = TRUE
)
seg = extract_segments(doc)
# }

Run the code above in your browser using DataLab