|
6 | 6 | "source": [
|
7 | 7 | "# Leaflet cluster map of talk locations\n",
|
8 | 8 | "\n",
|
9 |
| - "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." |
| 9 | + "Assuming you are working in a Linux or Windows Subsystem for Linux environment, you may need to install some dependencies. Assuming a clean installation, the following will be needed:\n", |
| 10 | + "\n", |
| 11 | + "```bash\n", |
| 12 | + "sudo apt install jupyter\n", |
| 13 | + "sudo apt install python3-pip\n", |
| 14 | + "pip install getorg --upgrade\n", |
| 15 | + "```\n", |
| 16 | + "\n", |
| 17 | + "After which you can run this from the `_talks/` directory, via:\n", |
| 18 | + "\n", |
| 19 | + "```bash\n", |
| 20 | + " jupyter nbconvert --to notebook --execute talkmap.ipynb --output talkmap_out.ipynb\n", |
| 21 | + "```\n", |
| 22 | + " \n", |
| 23 | + "The `_talks/` directory 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." |
10 | 24 | ]
|
11 | 25 | },
|
12 | 26 | {
|
|
17 | 31 | },
|
18 | 32 | "outputs": [],
|
19 | 33 | "source": [
|
| 34 | + "# Start by installing the dependencies\n", |
20 | 35 | "!pip install getorg --upgrade\n",
|
21 | 36 | "import glob\n",
|
22 | 37 | "import getorg\n",
|
|
31 | 46 | },
|
32 | 47 | "outputs": [],
|
33 | 48 | "source": [
|
| 49 | + "# Collect the Markdown files\n", |
34 | 50 | "g = glob.glob(\"*.md\")"
|
35 | 51 | ]
|
36 | 52 | },
|
|
42 | 58 | },
|
43 | 59 | "outputs": [],
|
44 | 60 | "source": [
|
| 61 | + "# Prepare to geolocate\n", |
45 | 62 | "geocoder = Nominatim(user_agent=\"academicpages.github.io\")\n",
|
46 | 63 | "location_dict = {}\n",
|
47 | 64 | "location = \"\"\n",
|
|
57 | 74 | },
|
58 | 75 | "outputs": [],
|
59 | 76 | "source": [
|
60 |
| - "\n", |
| 77 | + "# Perform geolocation\n", |
61 | 78 | "for file in g:\n",
|
62 | 79 | " with open(file, 'r') as f:\n",
|
63 | 80 | " lines = f.read()\n",
|
|
80 | 97 | },
|
81 | 98 | "outputs": [],
|
82 | 99 | "source": [
|
| 100 | + "# Save the map\n", |
83 | 101 | "m = getorg.orgmap.create_map_obj()\n",
|
84 | 102 | "getorg.orgmap.output_html_cluster_map(location_dict, folder_name=\"../talkmap\", hashed_usernames=False)"
|
85 | 103 | ]
|
|
0 commit comments