Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

legs2route

Convert a leg-structured route to a route-structured route


Description

Convert a leg-structured route to a route-structured route

Usage

legs2route(legsdf)

Arguments

legsdf

a legs-structured route, see route

See Also

geom_path in ggplot2

Examples

## Not run:  requires Google API key, see ?register_google

(legs_df <- route("houston","galveston"))
legs2route(legs_df)

(legs_df <- route(
  "marrs mclean science, baylor university",
  "220 south 3rd street, waco, tx 76701", # ninfa"s
  alternatives = TRUE))

legs2route(legs_df)




from <- "houston, texas"
to <- "waco, texas"
legs_df <- route(from, to)


qmap("college station, texas", zoom = 8) +
  geom_segment(
    aes(x = start_lon, y = start_lat, xend = end_lon, yend = end_lat),
    colour = "red", size = 1.5, data = legs_df
  )
# notice boxy ends

qmap("college station, texas", zoom = 8) +
  geom_leg(
    aes(x = start_lon, y = start_lat, xend = end_lon, yend = end_lat),
    colour = "red", size = 1.5, data = legs_df
  )
# notice overshooting ends

route_df <- legs2route(legs_df)
qmap("college station, texas", zoom = 8) +
  geom_path(
    aes(x = lon, y = lat),
    colour = "red", size = 1.5, data = route_df, lineend = "round"
  )




## End(Not run)

ggmap

Spatial Visualization with ggplot2

v3.0.0
GPL-2
Authors
David Kahle [aut, cre] (<https://orcid.org/0000-0002-9999-1558>), Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>), Scott Jackson [aut], Mikko Korpela [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.