OSM, Cycling, R

Tim Foster @fozy81

March 16, 2016

The potted history of a shiny app

  • Cycling
  • OpenStreetMap (OSM)
  • R / shiny

Rating the cycle infrastructure in your area

Cycling

Cycling

Traffic

Cycling

Cycling

  • Cyclehack - Glasgow 2014 & 2015
  • Can we use data to rate and improve cycle paths?

Where's the data?

  • OS
  • Google
  • Strava
  • Others? (aerial imagery - ML?)

OpenStreetMap

  • Free, Open Data, Worldwide
  • Terrabyte of data
  • Constantly updated + lots of cycling information
  • It's amazing!

OpenStreetMap + cycle

OpenStreetMap edit video

OpenStreetMap

OpenStreetMap

  • Data is patchy
  • Inconsistent tagging/structure
  • Quantitive not qualitive

Using OpenStreeMap

  • osmar package in R - that's great to get started
  • overpass turbo API - no package yet!
  • Large downloads need to use postgres + postgis database - bit of a fiddle

Workflow

  • Data downloaded (Geofabrik & Metro Extracts)
  • Import in postgres database
  • Use ROBDC in R to query postgres for summary stats

OSM > POSTGRES > R

Stats

Inspired by: * SIMD - Indexes/Ranking

  • Water Framework Directive- Observed/Expected

Stats

  • Takes Amsterdam as the best example of cycling infrastructure / highest number of people cycling
  • Compares all other areas to Amsterdam (after standardising) for:
    • Cycle parking
    • Cycle paths
    • National cycle routes

Stats

  • Uses Amsterdam as expected/ideal level of cycle infrastructure
  • Compares any given area to Amsterdam
  • Standardising uses area size and total length of road

Code bit

  • stats are in the github package 'bikr'
  • www.github.com/fozy81/bikr

Visualising

  • 1 Static web page - maps created in R
  • 2 Started with python (flask web server) + javascript
  • 3 Shiny framework - back to using R

Demo

Future

  • need help with postGIS
  • R improvements
  • download the package - pull requests!

Thank you

Remember: Cycling makes you a better R coder!

@fozy81