Tim Hortons and Starbucks in Canada using Open Street Map
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.
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.
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.
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.
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.
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.