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] 1804    5
knitr::kable (head (d))
from dlim id x y
977473118 100 1143452406 76.46110 15.34093
977473118 100 1143452538 76.46162 15.34113
977473118 100 1143452406 76.46110 15.34093
977473118 200 2627422264 76.46112 15.34006
977473118 200 2627422262 76.46119 15.34023
977473118 200 1143452213 76.46239 15.34117

This function returns in this case a data.frame with the columns shown above and 1,804 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 
##  193  269  358  447  537

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.