I am interested in learning how to work with Road Network Files in R.
For example, I would be interested in finding out the driving distance between the following two (Canadian) addresses:
- CN Tower: 290 Bremner Blvd, Toronto, ON M5V 3L9
- Toronto Airport: 6301 Silver Dart Dr, Mississauga, ON L5P 1B2
In the past, I would have used an API such as the OpenStreetMap (OSM):
library(tmap)
remotes::install_github("riatelab/osrm")
q1 = geocode_OSM("6301 Silver Dart Dr, Mississauga, ON L5P 1B2")
q2 = geocode_OSM("290 Bremner Blvd, Toronto, ON M5V 3L9")
q1 = as.numeric(q1$coords)
q2 = as.numeric(q2$coords)
q1_lat = q1[1]
q1_long = q1[2]
q2_lat = q2[1]
q2_long = q2[2]
route = osrmRoute(src = c(q1[1], q1[2]) , dst = c(q2[1], q2[2]), osrm.profile = "car")
> route$distance
[1] 26.2836
As we can see here, the driving distance between these two points is 26.2 KM (which is quite close to distance obtained from Google Maps)
My Question: I would now like to try and do something similar using a Road Network File.
For example, I found the following file which contains information about the Road Networks (2021 Census – Road network file). I then downloaded this to my computer in .shp format (i.e. shapefile).
Based on such a file of Road Networks, is it possible to find out the "driving distance" between any two addresses (whether in "language address" or geographical coordinates)?
Thanks!
Note: This file appears to be quite large and I am not sure if my computer can fully load it - is it possible to command the computer to only import a smaller portion of this file? (e.g. import where province = ontario , import where city = toronto)