osrmIsochrone: Get Polygons of Isochrones

View source: R/osrmIsochrone.R

osrmIsochroneR Documentation

Get Polygons of Isochrones

Description

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.

Usage

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")
)

Arguments

loc

origin point. loc can be:

  • a vector of coordinates (longitude and latitude, WGS 84),

  • a data.frame of longitudes and latitudes (WGS 84),

  • a matrix of longitudes and latitudes (WGS 84),

  • an sfc object of type POINT,

  • an sf object of type POINT.

If loc is a data.frame, a matrix, an sfc object or an sf object then only the first row or element is considered.

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.

Value

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.

Examples

## 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)

osrm documentation built on March 31, 2023, 11:55 p.m.