Leaflet cluster map of talk locations

Run this from the _talks/ directory, which contains .md files of all your talks. This scrapes the location YAML field from each .md file, geolocates it with geopy/Nominatim, and uses the getorg library to output data, HTML, and Javascript for a standalone cluster map.

In [1]:
!pip3 install getorg --upgrade
import glob
import getorg
from geopy import Nominatim
Requirement already up-to-date: getorg in /usr/local/lib/python3.7/site-packages (0.3.1)
Requirement already satisfied, skipping upgrade: retrying in /usr/local/lib/python3.7/site-packages (from getorg) (1.3.3)
Requirement already satisfied, skipping upgrade: geopy in /usr/local/lib/python3.7/site-packages (from getorg) (1.21.0)
Requirement already satisfied, skipping upgrade: pygithub in /usr/local/lib/python3.7/site-packages (from getorg) (1.47)
Requirement already satisfied, skipping upgrade: six>=1.7.0 in /Users/deannabeatty/Library/Python/3.7/lib/python/site-packages (from retrying->getorg) (1.14.0)
Requirement already satisfied, skipping upgrade: geographiclib<2,>=1.49 in /usr/local/lib/python3.7/site-packages (from geopy->getorg) (1.50)
Requirement already satisfied, skipping upgrade: pyjwt in /usr/local/lib/python3.7/site-packages (from pygithub->getorg) (1.7.1)
Requirement already satisfied, skipping upgrade: requests>=2.14.0 in /usr/local/lib/python3.7/site-packages (from pygithub->getorg) (2.23.0)
Requirement already satisfied, skipping upgrade: deprecated in /usr/local/lib/python3.7/site-packages (from pygithub->getorg) (1.2.9)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub->getorg) (2020.4.5.1)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub->getorg) (2.9)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub->getorg) (1.25.9)
Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub->getorg) (3.0.4)
Requirement already satisfied, skipping upgrade: wrapt<2,>=1.10 in /Users/deannabeatty/Library/Python/3.7/lib/python/site-packages (from deprecated->pygithub->getorg) (1.11.2)
Iywidgets and ipyleaflet support disabled. You must be in a Jupyter notebook to use this feature.
Error raised:
No module named 'ipyleaflet'
Check that you have enabled ipyleaflet in Jupyter with:
    jupyter nbextension enable --py ipyleaflet
In [2]:
g = glob.glob("*.md")
In [3]:
geocoder = Nominatim()
location_dict = {}
location = ""
permalink = ""
title = ""
/Users/deannabeatty/Library/Python/3.7/lib/python/site-packages/ipykernel_launcher.py:1: DeprecationWarning: Using Nominatim with the default "geopy/1.21.0" `user_agent` is strongly discouraged, as it violates Nominatim's ToS https://operations.osmfoundation.org/policies/nominatim/ and may possibly cause 403 and 429 HTTP errors. Please specify a custom `user_agent` with `Nominatim(user_agent="my-application")` or by overriding the default `user_agent`: `geopy.geocoders.options.default_user_agent = "my-application"`. In geopy 2.0 this will become an exception.
  """Entry point for launching an IPython kernel.
In [4]:
for file in g:
    with open(file, 'r') as f:
        lines = f.read()
        if lines.find('location: "') > 1:
            loc_start = lines.find('location: "') + 11
            lines_trim = lines[loc_start:]
            loc_end = lines_trim.find('"')
            location = lines_trim[:loc_end]
                            
           
        location_dict[location] = geocoder.geocode(location)
        print(location, "\n", location_dict[location])
 
 None
 
 None
 
 None
In [5]:
m = getorg.orgmap.create_map_obj()
getorg.orgmap.output_html_cluster_map(location_dict, folder_name="../talkmap", hashed_usernames=False)
Out[5]:
'Written map to ../talkmap/'
In [ ]: