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.
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.
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.
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.
In addition, Deckgl allows many different types of charts and plots. One example is the scatterplot.
With Leaflet it is also to plot locations with markers.
Using customized markers, marker plots in Leaflet allow one more lever for communicating your findings.
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.
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.
For geocoding locations into latitude and longitude coordinates one can use the Open Street Map API. In R packages such as osmdata and tidygeocoder provide functions that support this API, allowing for easy and pain-free geocoding.