osrmIsodistance: Get Polygons of Isodistances

View source: R/osrmIsodistance.R

osrmIsodistanceR Documentation

Get Polygons of Isodistances

Description

This function computes areas that are reachable within a given road distance from a point and returns the reachable regions as polygons. These areas of equal travel distance are called isodistances.

Usage

osrmIsodistance(
  loc,
  breaks = seq(from = 0, to = 10000, length.out = 4),
  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 isodistance areas, in meters.

exclude

pass an optional "exclude" request option to the OSRM API.

res

number of points used to compute isodistances, one side of the square grid, the total number of points will be res*res. Increase res to obtain more detailed isodistances.

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 isodistances.
It contains 3 fields:

  • id, an identifier

  • isomin, the minimum value of the isodistance polygon in meters

  • isomax, the maximum value of the isodistance polygon in meters

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 <- osrmIsodistance(loc = c(13.43, 52.47), breaks = seq(0, 500, 100))
# Map
plot(iso["isomax"], breaks = sort(unique(c(iso$isomin, iso$isomax))))

# Get isochones with an sf POINT
iso2 <- osrmIsodistance(loc = apotheke.sf[11, ], breaks = seq(0, 500, 100))
# 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 May 29, 2024, 9:29 a.m.