Spatial data visualization in Python and R

This article introduces the concept of spatial data visualization pipeline in R or Python. I have written various posts covering spatial data visualization for supply chain analysis and management, in both R and Python. Relevant libraries comprise e.g. Leaflet in Python, leaflet in R, deckgl in R and ggmap in R. I have also demonstrated how one can create spatial data animations in R, using a framework build around ggmap and gganimate.

In this post I want to introduce some exemplary module-stacks, or pipelines, for implementing spatial data visualization in R or Python. As I have conducted most of my spatial data visualization using R I will put my focus on some of these packages. But Python offers just as many possibilities.

The core steps in any spatial data visualization and analysis project are to.

  1. read in the data
  2. clean, manipulate and arrange the data
  3. geocode the data to obtain latitude and longitude coordinates
  4. plot / visualize the data on a map

Below pipelines are just some examples for how one could implement above workflow.

Spatial data visualization pipeline in R: Geocode with tidygeocoder, visualize with folium

Tidygeocoder allows for easy geocoding and folium allows for e.g. heatmapping.

Another pipeline in R: Geocode with tidygeocoder, visualize with ggmap

Ggmap allows for ggplot2 syntax-like map-based data visualization. Moreover, as stated in the introduction of this article, ggmap and gganimate can be combined to create spatial data animations.

Example in R: Geocode with osmdata, get a map from mapbox and plot with deckgl

Deckgl is a great package for visualizing supply chain data in 3D, e.g. with 3D heatmaps / histograms. Map tiles can e.g. be created on the Mapbox website.

Spatial data visualization pipeline example in Python: Geocoding with Geopy, plotting with Leaflet

In Python one can e.g. use the Geopy module for geocoding, using the Nominatim service. Visualizations, including e.g. heatmaps, can be generated using e.g. the Leaflet Python module.

Spatial data visualization pipeline for map-based GUIs, with shiny app development

As I have also introduced a coding example in R implementing the shiny package for spatial data visualization I want to conclude this post by suggesting a pipeline that embeds its visualization in shiny. Deckgl is a great package, but you could e.g. also use leaflet – i.e. develop a leaflet shiny app.

I have written another post with an overview of specifically spatial data visualization packages in R. It can be found here.

You May Also Like

Leave a Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.