forked from JTT94/jtt94.github.io
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtalkmap.py
More file actions
Latest commit
47 lines (31 loc) · 1.16 KB
/
Copy pathtalkmap.py
File metadata and controls
47 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# # Leaflet cluster map of talk locations
#
# (c) 2016-2017 R. Stuart Geiger, released under the MIT license
#
# 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.
#
# Requires: glob, getorg, geopy
importglob
importgetorg
fromgeopyimportNominatim
g=glob.glob("*.md")
geocoder=Nominatim()
location_dict= {}
location=""
permalink=""
title=""
forfileing:
withopen(file, 'r') asf:
lines=f.read()
iflines.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])
m=getorg.orgmap.create_map_obj()
getorg.orgmap.output_html_cluster_map(location_dict, folder_name="../talkmap", hashed_usernames=False)