This code maps artisanal cheeses extracted from the Canadian Cheese Directory open data. It was developed in collaboration with Sara Alain as a Hackfest project at the Code4Lib North meeting 2015.
The result is a geoJSON file with geolocated cheese specialities and dairy farms.
The CSV file downloaded from the Canadian Open Data portal is first filtered to only contain "artisanal" cheese specialities. It is then run through cheesemap.py, which uses the YellowPages Places API to try and find the address of each dairy farm. Only the name of the farm and the province code is available in the source file, so sadly only about 50% of entries can be thus mapped. The result is another CSV file that contains extra columns for latitude and longitude. Since the free API only allows 300 queries per day, the same CSV file can be re-run through the script. Only rows where the lat and lon pair is missing will then be queried. This allows the list to be gelolocated in batches.
An earlier version of the script used the Google Places API instead, but this was found to be even less reliable.
Note that an API key needs to be obtained from the YellowAPI service for the script to work.
The resulting CSV file is then run through csv2json.py to be turned into a geoJSON file, to be mapped by GitHub's built-in geoJSON engine.
- This is obviously just for fun and not very useful. The map does not display URLs, many producers fail to be mapped and are thus not displayed. Also, we still haven't tasted all the cheese!
- To check if the YellowPages API returned the right farm, a fuzzy text comparison (using fuzzywuzzy) is done between the name that was in the input data and the one returned by the API. This does not currently work very well, especially with French names. So more entries fail to be mapped because of this.
- I'm pretty sure at some point the latitude was substitued with the longitude and vice-versa. The result is fine, but don't trust the variable names.
- It would be nice not having to filter the input CSV file manually.
- It would also be nice to embed this map in an actual website and start playing around with leaflet.js so that it looks nicer.
- We found this geoJSON validator tool useful for debugging.