The dodgrpackage includes three functions for calculating iso-contours from one or more points of origin: dodgr_isodists() for contours of equal distance; dodgr_isochrones() for contours of equal time; and dodgr_isoverts() to return full set of vertices within defined isodistance or isochrone contours.

Each of these functions is fully vectorised to accept both multiple origin points and multiple contours. Each returns a single data.frame object, with a column specifying either the distance limit (as dlim for dodgr_isodists() ,or tlim for dodgr_isochrones()). The functions are also internally parallelised for efficient calculation.

dodgr_isodists

The dodgr_isodists() function calculates contours of equal distance from one or more points of origin.

graph <- weight_streetnet (hampi)
from <- sample (graph$from_id, size = 100)
dlim <- c (1, 2, 5, 10, 20) * 100
d <- dodgr_isodists (graph, from = from, dlim)
dim (d)
## [1] 1739    5
knitr::kable (head (d))
from dlim id x y
313796392 200 313796392 76.47775 15.34182
313796392 200 3921522526 76.47636 15.34224
313796392 200 313796392 76.47775 15.34182
313796392 500 2398958016 76.48073 15.34101
313796392 500 2398958016 76.48073 15.34101
313796392 1000 571423844 76.47139 15.33873

This function returns in this case a data.frame with the columns shown above and 1,739 points defining the isodistance contours from each origin (from) point, at the specified distances of 100, 200, 500, 1000, 2000 metres. There are naturally more points defining the contours at longer distances:

table (d$dlim)
## 
##  100  200  500 1000 2000 
##  213  263  346  425  492

The points defining the contours are arranged in an anticlockwise order around each point of origin, and so can be directly visualised using base graphics functions. This is easier to see by using just a single point of origin:

from <- sample (graph$from_id, size = 1)
dlim <- c (1, 2, 5, 10, 20) * 100
d <- dodgr_isodists (graph, from = from, dlim)
cols <- terrain.colors (length (dlim))
index <- which (d$dlim == max (d$dlim)) # plot max contour first
plot (d$x [index], d$y [index], "l", col = cols [1],
      xlab = "longitude", ylab = "latitude")
for (i in seq (dlim) [-1]) {
    index <- which (d$dlim == rev (dlim) [i])
    lines (d$x [index], d$y [index], col = cols [i], lwd = i + 1)
}

The contours are convex hulls, so can not be guaranteed to entirely contain all internal contours, as that plot clearly reveals.