Shiny App: Drive Time Isochrones

November 5, 2018
sf leaflet osrm viridis shiny geospatial R

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.

library(osrm)
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

Introduction to Geospatial Analysis in R

September 30, 2018
R geospatial sf shiny raster sp ggplot2 leaflet osrm httr rvest

Shiny Gadget: Fit Distributions

September 2, 2018
R fitur

fitur 0.6.1 Release

September 1, 2018
R fitur