Skip to contents

ors_accessibility returns isochrone or isodistance data for a set of source points, either as polygons or as a raster.

Usage

ors_accessibility(
  src,
  profile = NULL,
  range = c(200, 300),
  attributes = "area",
  intersections = FALSE,
  interval = 30,
  location_type = c("start", "destination"),
  range_type = c("time", "distance"),
  smoothing = 25,
  area_units = c("m", "km", "mi"),
  units = c("m", "km", "mi"),
  rasterize = FALSE,
  raster_resolution = c(100, 100),
  instance = NULL,
  ...,
  params = NULL
)

Arguments

src

[sf/sfc]

Source dataset containing point geometries that should be routed from.

profile

[character]

Means of transport as supported by OpenRouteService. Defaults to the first profile in a call to get_profiles. For ors_shortest_distances, profile can be a character vector, for all other functions it needs to be a character scalar. For details on all profiles, refer to the backend reference.

range

[character]

If length-1, specifies the maximum range which can be further broken down using the argument interval. If of length larger than 1, specifies manual breaks. The unit can be controlled using the argument range_type.

attributes

[character]

Additional features to be included the output. Only relevant if rasterize = FALSE. Can be one of "area", "reachfactor" and "total_pop".

intersections

[logical]

Whether to return the overlapping area of seperate isochrones. If TRUE, the response will not contain the actual isochrones but only their intersections. See below for details. Defaults to FALSE.

interval

[integer]

If range is a length-1 vector, defines the distance interval to break down the isochrones. For example, if range is 300 and interval is 50, creates 6 isochrones where each isochrone is 50 units further from the center. If length(range) > 1, this argument is ignored. Defaults to 30.

location_type

[character]

Whether to route from ("start") or to ("destination") the points of the input data. Defaults to "start".

range_type

[character]

Type of distance that the calculations should be based on. "time" produces isochrones while "distance" produces isodistance polygons. Defaults to "time".

smoothing

[integer]

Smoothing factor between 0 and 100 to be applied to the polygon geometries. For details, refer to the API playground. Defaults to 25.

area_units

[character]

Distance unit to use for the area attribute from attributes. Defaults to "m".

units

[character]

Units to be used for the range argument if range_type = "distance". Defaults to "m".

rasterize

[logical]

If FALSE, returns the isochrone polygon geometries. If TRUE, aggregates polygon distance values onto a vector grid and then rasterizes the vector grid to a SpatRaster object created using rast. When rasterizing, only the distance value is preserved while all variables specified in attributes are discarded. Requires the terra package to be installed. Defaults to FALSE.

raster_resolution

[numeric]

If rasterize = TRUE, specifies the resolution of the template raster. Corresponds to the number of cells in each direction (x, y). This argument is passed on to st_make_grid and rast. Defaults to 100x100.

instance

[ors_instance]

Object of an OpenRouteService instance that should be used for route computations. It is recommended to use ors_instance to set an instance globally. This argument should only be used if activating an instance globally is not feasible.

...

Additional arguments passed to the ORS API. This includes all options that modify the routing results. For details on each argument, refer to the API playground and documentation. Reasonable arguments include avoid_borders, avoid_countries, avoid_features, avoid_polygons, profile parameters, and vehicle_type.

params

List of additional arguments passed to the ORS API. See ors_params for details.

Value

If rasterize = FALSE and intersections = FALSE, returns an sf object containing the isochrone or isodistance polygon geometries as well as additional attributes. Each polygon's outer lines represent places of equal distance or travel time from or to the respective point in the source dataset.

If rasterize = TRUE, returns a raster object with a discrete value classification.

If intersections = TRUE, returns an sf dataframe containing the intersections between two respective isochrones and their indices. The response contains four indices. Index names starting a_* specify the first isochrone of the intersection and names starting with b_* specify the second isochrone. Index names ending with *_index correspond to the group_index of the isochrones. Index names ending with *_range correspond to the index of values in the range argument. For example, if range = c(200, 300), a a_range of 1 would correspond to 300. Taken together, each intersection can be assigned to two isochrone and each isochrone can be identified using their group index and their respective range.

Examples

if (FALSE) { # \dontrun{
data("pharma")

# Returns a polygon sf dataframe divided by four 15 minute time breaks.
# Also contains information on the area and population inside the isochrones.
ors_accessibility(
  pharma,
  profile = "driving-car",
  range = c(900, 1800, 2700, 3600),
  attributes = c("area", "total_pop"),
  location_type = "start",
  range_type = "time",
  rasterize = TRUE
)

# Returns a raster image classified by 3 distance intervals
ors_accessibility(
  pharma,
  profile = "driving-car",
  range = c(1000, 5000, 10000),
  location_type = "destination",
  range_type = "distance",
  rasterize = TRUE
)

# Returns a polygon sf dataframe that is broken down every 50 meters up until
# the maximum distance of 500 meters.
ors_accessibility(
  pharma,
  profile = "cycling-regular",
  range = 500,
  location_type = "start",
  interval = 50,
  range_type = "distance"
)

# Returns the intersections of the above isochrones
ors_accessibility(
  pharma,
  intersections = TRUE,
  profile = "cycling-regular",
  range = 500,
  location_type = "start",
  interval = 50,
  range_type = "distance"
)
} # }