talkmap and nominatim

1 minute read

Published:

The original repository for this webpage comes with an utility for creating interactive leaflet cluster map of talk locations. The script talkmap.py basically scraps talk location info from markdown files listed inside _talks/ and creates the map using geopy and getorg.

In my version of the map, I wanted to show the talk info (institution and year) instead of just location on hover. Also instead of editing the html/Javascript outputs I wanted to try getting it done with only a python script using nominatim geocoder.

My talk info are only listed in the pdf of my CV, and so I created a text file map.dat listing them, e.g.

University of Toronto 2021
Northwestern University 2021
...

and running a slightly modified version of the original script:

import getorg
from geopy import Nominatim as gpN

m = getorg.orgmap.create_map_obj()
gc = gpN(user_agent='x')

with open('map.dat') as f:
    lines = f.readlines()
    locs = [line.strip() for line in lines]

locdict = {}
for loc in locs: locdict[loc] = gc.geocode(loc)

getorg.orgmap.output_html_cluster_map(locdict)

it creates a nice map at cluster_map/map.html. It looked ok but upon closer inspection I noticed 1 missing entry and 2 quite off: “JHU - Applied Physics Lab 2019” was missing, “SETI Institute 2016” was somewhere in India, and “University of Arizona 2020” was in Phoenix instead of Tucson. In general the missing ones can be caught by checking None with something like missing = [loc for loc in locs if locdict[loc] == None].

Obviously this is not an issue of geopy, only a limitation of nominatim; it would probably work right away with GoogleV3 or Bing (but you need to setup API keys and potentially pay). With nominatim, the first and last ones can be fixed by slightly changing the query - e.g., by not abbreviating JHU, and by specifying Tucson. The one for SETI is still problematic though. I’ve tried a number of different queries, but they all pointed to somewhere in Africa or South Asia. The closest I got to the actual location in Mountain View, CA is Mountain View, CA SETI which points to the radio observatory 300 miles north in Shasta country… at least its in the same state.