Which Tim Hortons Did Santa Go: Interactive visualization of Latitude and Longitude on Maps With Plotly and Python

An easy way to create interactive geographical scatter plots

Alina Zhang
4 min readDec 24, 2020

--

All Images in the Article Created by Author

“Where Tim Hortons is, that’s my home.” Tim Hortons, a Starbucks-like coffee shop founded by a hockey player, always has special meanings for Canadians. It is Canada’s largest fast-food restaurant chain with 4,846 stores in 14 countries, by December 31, 2018, according to Wikipedia. In this article, we will use a dataset of Tim Hortons Locations from Kaggle to show how to create interactive visualizations of latitude and longitude on maps with Plotly and Python. From these plots, we can easily answer a question:

Which Tim Hortons is the one Santa Claus usually visits?

Import libraries:

Load the dataset:

Keep only the columns we need in this project:

Check if there are missing values:

As we saw, there are 4346 entries with no missing values.

Plot all stores on a world map:

import plotly.express as pxfig = px.scatter_geo(df,lat=df.latitude,lon=df.longitude,hover_name="_id",scope='world')fig.show()# Save the image
fig.write_image("./TimHortonsOnWorldMap.png", width=1200, height=800)

As illustrated in the image, the addresses from the dataset are mostly in North America. So that it is not a complete dataset for all Tim Hortons globally as it was claimed in Kaggle. It doesn’t matter to us because the…

--

--

Alina Zhang