Visualising Rally Route Stages (with help from rayshader and some ecologists…)

Inspired by some 3D map views generated using the rayshader and rgl R packages, I wondered how easy it would be to render some 3D maps of rally stages.

It didn’t take too long to get a quick example up and running but then I started wondering what else I could do with route and elevation data. And it turns out, quite a lot.

The result of my tinkerings to date is at It concentrates soley on a "static analysis" of rally routes: no results, no telemetry, just the route.

Along the way, it covers the following topics:

  • using R spatial (sp) and simple features (sf) packages to represent routes;
  • using the leaflet, mapview and ggplot2 packages to render routes;
  • annotating and splitting routes / linestrings;
  • downloading elevation rasters using elevatr;
  • using the raster package to work with elevation rasters;
  • a review of map projections;
  • exploring various ways of rendering rasters and annotating them with derived terrain features;
  • rendering elevation rasters in 2D using rayshader;
  • an aside on converting images to elevation rasters;
  • rendering and cropping elevation rasters in 3D using rayshader;
  • rendering shadows for particular datetimes at specific locations (suncalc);
  • stage route analysis: using animal movement trajectory analysis tools (trajr, amt, rLFT) to characterise stage routes;
  • stage elevation visualisation and analysis (including elevation analysis using slopes);
  • adding OpenStreetMap data inclduing highways and buildings to maps (osmdata);
  • steps towards creating a road book / tulip map using by mapping stage routes onto OSM road networks (sfnetworks, dodgr).

Along the way, I had to learn various knitr tricks, eg for rendering images, HTML and movies in the output document.

The book itself was written uisng Rmd and then published via bookdown and Github Pages. The source repo is on Github at RallyDataJunkie/visualising-rally-stages.

Author: Tony Hirst

I'm a Senior Lecturer at The Open University, with an interest in #opendata policy and practice, as well as general web tinkering...

5 thoughts on “Visualising Rally Route Stages (with help from rayshader and some ecologists…)”

    1. Thanks.. a lot of code implementing functions found in commercial products is out there, if you are prepared to look for it. The trick then comes down to finding out how to get the thing you have into the function you found, and whatever it spits out back into a representation you can work with. A lot of folk are way too lazy to be be properly lazy (i.e. they are too bad-form-of-lazy to put the time in to find and find out how to use stuff that already exists (the good-form-of-lazy ;-).

      1. Indeed, the datasets are out there. And the transforms, to get the views you want. Just.have string them togther, couple them up and keep trying. Ask a few questions and keep trying. Good too, you documented as you went down the rabbit hole, time that can be saved in future as you say in your follow-up blog post. Truly narrating your work Jon Udell style.

Comments are closed.

%d bloggers like this: