View source: R/osrmIsochrone.R
osrmIsochrone | R Documentation |
This function computes areas that are reachable within a given time span from a point and returns the reachable regions as polygons. These areas of equal travel time are called isochrones.
osrmIsochrone(
loc,
breaks = seq(from = 0, to = 60, length.out = 7),
exclude,
res = 30,
returnclass,
osrm.server = getOption("osrm.server"),
osrm.profile = getOption("osrm.profile")
)
loc |
origin point.
If |
breaks |
a numeric vector of break values to define isochrone areas, in minutes. |
exclude |
pass an optional "exclude" request option to the OSRM API. |
res |
number of points used to compute isochrones, one side of the square grid, the total number of points will be res*res. Increase res to obtain more detailed isochrones. |
returnclass |
deprecated. |
osrm.server |
the base URL of the routing server. getOption("osrm.server") by default. |
osrm.profile |
the routing profile to use, e.g. "car", "bike" or "foot" (when using the routing.openstreetmap.de test server). getOption("osrm.profile") by default. |
The output of this function is an sf MULTIPOLYGON of isochrones.
It contains 3 fields:
id, an identifier
isomin, the minimum value of the isochrone polygon in minutes
isomax, the maximum value of the isochrone polygon in minutes
If loc is a vector, a data.frame or a matrix the coordinate
reference system (CRS) of the output is EPSG:4326 (WGS84).
If loc is an sfc or sf object, the output has the same CRS
as loc.
## Not run:
library(sf)
apotheke.sf <- st_read(system.file("gpkg/apotheke.gpkg", package = "osrm"),
quiet = TRUE
)
# Get isochones with lon/lat coordinates
iso <- osrmIsochrone(loc = c(13.43, 52.47), breaks = seq(0, 12, 2))
# Map
plot(iso["isomax"], breaks = sort(unique(c(iso$isomin, iso$isomax))))
# Get isochones with an sf POINT
iso2 <- osrmIsochrone(loc = apotheke.sf[11, ], breaks = seq(0, 12, 2))
# Map
if (require("mapsf")) {
mapsf::mf_map(
x = iso2, var = "isomin", type = "choro",
breaks = sort(unique(c(iso2$isomin, iso2$isomax))),
pal = "Burg", border = NA, leg_pos = "topleft",
leg_val_rnd = 0,
leg_frame = TRUE, leg_title = "Isochrones\n(min)"
)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.