Learn R Programming

osrm (version 3.0.0)

osrmIsochrone: Get a SpatialPolygonsDataFrame of Isochrones

Description

Based on osrmTable, this function buids a SpatialPolygonsDataFrame of isochrones.

Usage

osrmIsochrone(loc, breaks = seq(from = 0, to = 60, length.out = 7))

Arguments

loc
a numeric vector of longitude and latitude (WGS84) or a SpatialPointsDataFrame or a SpatialPolygonsDataFrame of the origine point.
breaks
a numeric vector of isochrone values (in minutes).

Value

A SpatialPolygonsDateFrame of isochrones is returned. The data frame of the output contains four fields: id (id of each polygon), min and max (minimum and maximum breaks of the polygon), center (central values of classes).

See Also

osrmTable

Examples

Run this code
## Not run: 
# # Load data
# data("com")
# 
# # Get isochones with lon/lat coordinates, default breaks
# iso <- osrmIsochrone(loc = c(5.936036, 49.24882))
# plot(iso)
# points(5.936036, 49.24882, pch = 20, col = "red")
# 
# # Map
# if(require("cartography")){
#   osm <- getTiles(spdf = iso, crop = TRUE, type = "osmgrayscale")
#   tilesLayer(osm)
#   breaks <- sort(c(unique(iso$min), max(iso$max)))
#   cartography::choroLayer(spdf = iso, df = iso@data,
#                           var = "center", breaks = breaks,
#                           border = NA,
#                           legend.pos = "topleft",legend.frame = TRUE, 
#                           legend.title.txt = "Isochrones\n(min)", 
#                           add = TRUE)
# }
# 
# # Get isochones with a SpatialPointsDataFrame, custom breaks
# iso2 <- osrmIsochrone(loc = src[7,], breaks = seq(from = 0,to = 30, by = 5))
# 
# # Map
# if(require("cartography")){
#   osm2 <- getTiles(spdf = iso2, crop = TRUE, type = "osmgrayscale")
#   tilesLayer(osm2)
#   breaks2 <- sort(c(unique(iso2$min), max(iso2$max)))
#   cartography::choroLayer(spdf = iso2, df = iso2@data,
#                           var = "center", breaks = breaks2,
#                           border = NA,
#                           legend.pos = "topleft",legend.frame = TRUE, 
#                           legend.title.txt = "Isochrones\n(min)", 
#                           add = TRUE)
# }
# ## End(Not run)

Run the code above in your browser using DataLab