Reader small image

You're reading from  Interactive Data Visualization with Python - Second Edition

Product typeBook
Published inApr 2020
Reading LevelIntermediate
Publisher
ISBN-139781800200944
Edition2nd Edition
Languages
Right arrow
Authors (4):
Abha Belorkar
Abha Belorkar
author image
Abha Belorkar

Abha Belorkar is an educator and researcher in computer science. She received her bachelor's degree in computer science from Birla Institute of Technology and Science Pilani, India and her Ph.D. from the National University of Singapore. Her current research work involves the development of methods powered by statistics, machine learning, and data visualization techniques to derive insights from heterogeneous genomics data on neurodegenerative diseases.
Read more about Abha Belorkar

Sharath Chandra Guntuku
Sharath Chandra Guntuku
author image
Sharath Chandra Guntuku

Sharath Chandra Guntuku is a researcher in natural language processing and multimedia computing. He received his bachelor's degree in computer science from Birla Institute of Technology and Science, Pilani, India and his Ph.D. from Nanyang Technological University, Singapore. His research aims to leverage large-scale social media image and text data to model social health outcomes and psychological traits. He uses machine learning, statistical analysis, natural language processing, and computer vision to answer questions pertaining to health and psychology in individuals and communities.
Read more about Sharath Chandra Guntuku

Shubhangi Hora
Shubhangi Hora
author image
Shubhangi Hora

Shubhangi Hora is a data scientist, Python developer, and published writer. With a background in computer science and psychology, she is particularly passionate about healthcare-related AI, including mental health. Shubhangi is also a trained musician.
Read more about Shubhangi Hora

Anshu Kumar
Anshu Kumar
author image
Anshu Kumar

Anshu Kumar is a data scientist with over 5 years of experience in solving complex problems in natural language processing and recommendation systems. He has an M.Tech. from IIT Madras in computer science. He is also a mentor at SpringBoard. His current interests are building semantic search, text summarization, and content recommendations for large-scale multilingual datasets.
Read more about Anshu Kumar

View More author details
Right arrow

6. Interactive Visualization of Geographical Data

Learning Objectives

By the end of this chapter, you will be able to:

  • Use choropleth maps to represent data across geographical regions
  • Generate interactive choropleth maps, including choropleth maps depicting countries in the world and maps depicting states in the US, making layout changes to add functionality/aesthetic appeal, and adding animation
  • Generate interactive scatter plots on maps, including scatter plots indicating geolocations of places of interest and interactive bubble plots on maps
  • Generate interactive line plots on maps, including line plots indicating trajectories on a map

In this chapter, we'll learn about using interactive visualizations to depict data across geographical regions.

Introduction

In the previous chapters, you learned how to build interactive visualizations to present different features in a dataset across features that represent different strata and different time points. In this chapter, you are going to add another type of visualization to your skillset – plotting interactive visualizations with geographical data.

Most datasets generated in today's world involve some features depicting spatial or geographical aspects. For example, users of social media platforms are characterized by the different parts of the world they reside in, world development metrics are calculated for different countries in the world, transportation routes span many different locations across the globe, and so on. Therefore, it is essential to learn systematic ways to understand and present such information in a digestible yet insightful manner. This chapter will help you develop this ability by providing the necessary tools to generate a variety of plots...

Choropleth Maps

A choropleth map is a map of a region with different divisions colored to indicate the value of a specific feature in that division. This division may be a country, state, district, or any other well-documented area.

For example, you can visualize country-wise populations using a world map, state-wise populations on a country map, or the percentage of a population with access to a certain technology with a choropleth map.

Although the term choropleth map may or may not be familiar to you, as you go through the chapter, the concept of choropleth maps will become clearer.

Let's start exploring the different types of choropleth maps.

Worldwide Choropleth Maps

In the first visualization of this chapter, we are going to use the internet usage statistics published on Our World in Data (https://ourworldindata.org/internet) and present the percentage of the population using the internet in each country from 1990 to 2017. The dataset is hosted on the book...

Plots on Geographical Maps

While the previous plots were great for visualizing more global trends – such as countries or states – what if we want to represent features in smaller regions, say within individual states? In this section, you will learn how to draw scatter plots and bubble plots on maps. The most intuitive plot of this type is one that simply pinpoints certain locations of interest on the map.

Scatter Plots

We will be plotting the locations of Walmart stores on a map of the US. This dataset is publicly available at: https://github.com/plotly/datasets/ on the plotly website, and has been made available on the GitHub book repository. Let's look at an exercise on how to do so.

Exercise 49: Creating a Scatter Plot on a Geographical Map

In this exercise, we'll use the Walmart store openings dataset from 1962-2006 (available at: https://raw.githubusercontent.com/TrainingByPackt/Interactive-Data-Visualization-with-Python/master/datasets...

Summary

In this chapter, we presented three different types of visualization using geographical data choropleth maps, scatter plots and bubble plots on geographical maps, and line plots on geographical maps. Choropleth maps present aggregate statistics across different regions on geographical maps. Scatter plots are effective at indicating details regarding specific locations of interest, whereas bubble plots are useful for presenting count data per region on a map. Line plots are helpful in visualizing the routes of transportation systems, for instance.

These plots can easily be generated using the plotly express and graph_objects modules. Animation can be performed with respect to a discrete numeric feature in a dataset.

In the next chapter, we'll look at a few common pitfalls faced while creating visualizations and how to avoid them. Along with that, we'll also look at a cheat sheet for generating interactive visualizations.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Interactive Data Visualization with Python - Second Edition
Published in: Apr 2020Publisher: ISBN-13: 9781800200944
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (4)

author image
Abha Belorkar

Abha Belorkar is an educator and researcher in computer science. She received her bachelor's degree in computer science from Birla Institute of Technology and Science Pilani, India and her Ph.D. from the National University of Singapore. Her current research work involves the development of methods powered by statistics, machine learning, and data visualization techniques to derive insights from heterogeneous genomics data on neurodegenerative diseases.
Read more about Abha Belorkar

author image
Sharath Chandra Guntuku

Sharath Chandra Guntuku is a researcher in natural language processing and multimedia computing. He received his bachelor's degree in computer science from Birla Institute of Technology and Science, Pilani, India and his Ph.D. from Nanyang Technological University, Singapore. His research aims to leverage large-scale social media image and text data to model social health outcomes and psychological traits. He uses machine learning, statistical analysis, natural language processing, and computer vision to answer questions pertaining to health and psychology in individuals and communities.
Read more about Sharath Chandra Guntuku

author image
Shubhangi Hora

Shubhangi Hora is a data scientist, Python developer, and published writer. With a background in computer science and psychology, she is particularly passionate about healthcare-related AI, including mental health. Shubhangi is also a trained musician.
Read more about Shubhangi Hora

author image
Anshu Kumar

Anshu Kumar is a data scientist with over 5 years of experience in solving complex problems in natural language processing and recommendation systems. He has an M.Tech. from IIT Madras in computer science. He is also a mentor at SpringBoard. His current interests are building semantic search, text summarization, and content recommendations for large-scale multilingual datasets.
Read more about Anshu Kumar