Shiny App: Drive Time Isochrones

November 4, 2018

(This article was first published on R on Thomas Roh, and kindly contributed to R-bloggers)

The Open Source Routing Machine project is an excellent
resource for computing routing and travel time estimates for road networks. It is
an open source library that has a demo server to run API requests to.
I’ll only be using one of the services (isochrones which I’ll explain below)
in this blog post. To access the API there is a wonderful R package osrm that simplifies
the necessary code.

For various urban/transportation planning or market analysis, one will probably be interested
in the possible areas that can be reached by road within a certain amount of time. A
representation of that is called an isochrone. An isochrone is a spatial object
typically a polygon or multipolygon that shows a geographic region that can reach
a point within the specified travel time parameters. Programmatically in R,
all we need to do is specific the latitude and longtitude of interest and the
travel time.

osrmIsochrone(c(-95.9345,41.2565), breaks = 10)

The osrm package has some options behind the scenes that are preset for you.
The call above has set the server to the demo server (you can set up your own server
for reliability) and it has set the mode of transportation to “driving”. To
change the profile, you have to adjust the option “osrm.profile”. I’ve been able to use
“driving”, “bike”, and “walk” so far. You can find more documentation here:
OSRM Documentation and
osrm Github.

I’ve created a shiny app to show an example of building a sharp
interface for end users to easily specify the parameters and download the
geojson or shapefile for other uses. The app is in showcase mode (code is at the bottom)
so you can see what else is going on behind the scenes with the sf and leaflet package.

Link to application

To leave a comment for the author, please follow the link and comment on their blog: R on Thomas Roh. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)