Tim Hortons and Starbucks in Canada using Open Street Map
Introduction
In Canada, there really only seems to be two coffee chains, Tim Hortons and Starbucks. Each chain has fiercly loyal costumers and almost impossible to drive anywhere without seeing one or both dotting the streets and malls. This led to the question of where and how many of each are there in Canada.
Data
In order to locate Tim Hortons and Starbucks, Open Street Map (OSM) data was used. Specifically the Canada extract from GeoFabrik last modified on 2015-12-31T20:14:02Z.
Data Extraction
As in previous posts 1, 2, RPostgreSQL package will be used to connect to the database.
In order to get the list, the planet_osm_point table should be queried for partial matches to Starbucks and Tim Hortons. The names are set to uppercase for both to partial match search and values in table so letter case is not an issue. As well, the amenity should exist so that it is a cafe, restaraunt, or exists.
name | amenity | st_x | st_y | |
---|---|---|---|---|
1 | Tim Hortons | fast_food | -114.6626 | 51.79412 |
2 | Starbucks | cafe | -114.4748 | 51.18928 |
3 | Tim Hortons | cafe | -114.4725 | 51.18484 |
4 | Tim Hortons | restaurant | -114.4636 | 49.62061 |
5 | Starbucks | cafe | -114.2468 | 51.12408 |
6 | Tim Hortons | restaurant | -114.2400 | 51.10743 |
1938 | Tim Horton’s | cafe | -115.5760 | 51.18011 |
1939 | Starbucks | cafe | -115.5710 | 51.17814 |
1940 | Starbucks | cafe | -115.5553 | 51.14796 |
1941 | Tim Horton’s | cafe | -115.3621 | 51.10262 |
1942 | Starbucks | cafe | -115.3576 | 51.09280 |
1943 | Starbucks | cafe | -115.0585 | 49.51497 |
The last part of the data to extract is Canadian boarders of each province.
Data Clean Up
The data should be checked to make sure that the Tim Hortons and Starbucks are what we want.
Well, toilets should be checked to see if it is a Tim Hortons or not.
This will need to be removed, seems very specific instructions for finding the toilet location as well.
The last thing to check is the names:
This looks good.
The last part is to identify each Tim Hortons and Starbucks to make it easier to plot and count. With 0 for Starbucks and 1 for Tim Hortons.
Plot
Summary
The number of Starbucks location from OSM Data in Canada is: 677
The number of Tim Hortons location from OSM Data in Canada is: 1265
According to OSM data, there is nearly twice as many Tim Hortons locations in Canada. Where as Starbucks tends to be located around city centers, Tim Hortons seems to be dotted around Canada.
Issues
Since OSM data is crowd sourced, it may be that Tim Hortons locations are recorded more more often than Starbucks. Again, with crowd sourced data, Tim Hortons or Starbucks may not be properly represented in smaller cities and towns. Another issue is setting amenity to be not null, we may have missed some that were not tagged.