Spatial SCM data visualisation in R

In this post I want to provide a brief overview of useful packages in R for visualizing spatial data in R. The packages discussed are webglobe, deckgl, ggmap, ggplot2 and Leaflet.

webglobe

The webglobe package allows you to create e.g. bar charts on a 2D or 3D map. You can view your visualisation in your browser.

A visualisation of top US cities by Google keyword search intensity for “Burger”

Deckgl

Deckgl is a great visualisation package that generates javascript code containing your visualisation and map data. In order to use deckgl you will have to use Mapbox. On Mapbox you set up your map layout onto which deckgl allows you to plot your data.

Deckgl is great for 3D visualisation. Below is an example of an intensity plot for randomly distributed data points across Germany. Both column height and color allow you to communicate the content and distribution of your data.

Intensity plot using bar plots in deckgl (plotted onto mapbox background)

Adjusting column widths allows you to create 3D heatmaps. Below is an example in which I allow zero space between column bars. The heatmap shows random data points distributed normally around Dortmund city center in Germany. Column heigh and color indicate absolute observation frequency.

A 3D heatmap creater in Deckgl

In addition, Deckgl allows many different types of charts and plots. One example is the scatterplot.

Scatter map-plot generated in R, using the Deckgl package

Leaflet

Leaflet too is a Javascript library available to you in R. It is a very popular package for visualising spatial data. Using a set of different map layouts (amongst others e.g. Open Street Map) one can e.g. create scatterplots, heatmaps and markers. Below is an example of a heatmap created with Leaflet in R.

Visualizing Google search term intensity for “Pizza” vs “Burger” with Leaflet

With Leaflet it is also to plot locations with markers.

Top cities in Germany, by Google search intensity for “Pizza” vs. “Burger”

Using customized markers, marker plots in Leaflet allow one more lever for communicating your findings.

Customized markers display cities that intensively search for “Pizza” and “Burger”

ggmap

ggmap is another popular package for visualising spatial data in R. Most of its logic runs over the Google API. ggmap too allows you to generate heatmaps. Below us a standard example illustrating distribution of crime scenes near Houston, Texas.

Heatmaps with adjusted coloring, using ggmap in R

ggplot2

As one last example I want to show a map plot that I created using ggplot2. ggplot2 allows your to load map scales into your plot. Setting x and y scores equal to coordinates allows you to visualise the spatial aspects of your data in e.g. scatterplots.

A scatter map-plot generated using ggplot2

Leave a Reply

2 thoughts on “Spatial SCM data visualisation in R

Leave a Reply

Your email address will not be published. Required fields are marked *

Close

Meta