{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Find all OpenStreetMap edits by [@dhimmel](https://www.openstreetmap.org/user/dhimmel) of the Long Trail\n", "\n", "This notebook produces data for the blog post at .\n", "\n", "First use [osm-get-user-changeset-metadata](https://github.com/andrewharvey/osm-get-user-changeset-metadata) to download all changesets by user `dhimmel`:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "User 'dhimmel' (9376583)\n", "Account Created: 2019-01-22T00:17:27Z\n", "Changesets: 407\n", "Downloading Changesets between: 2019-01-22T00:17:27Z and now.\n", "100 / 407\n", "Downloading Changesets between: 2019-01-22T00:17:27Z and 2021-01-21T17:57:25Z.\n", "200 / 407\n", "Downloading Changesets between: 2019-01-22T00:17:27Z and 2020-08-31T01:05:41Z.\n", "300 / 407\n", "Downloading Changesets between: 2019-01-22T00:17:27Z and 2020-07-30T00:56:44Z.\n", "400 / 407\n", "Downloading Changesets between: 2019-01-22T00:17:27Z and 2019-01-30T21:54:23Z.\n", "407 / 407\n", "Downloading Changesets between: 2019-01-22T00:17:27Z and 2019-01-22T00:40:26Z.\n", "407 / 407\n" ] } ], "source": [ "! ./osm_get_user_changeset_metadata.sh dhimmel" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "import xml.etree.ElementTree as ET\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[PosixPath('9376583/1.xml'),\n", " PosixPath('9376583/2.xml'),\n", " PosixPath('9376583/3.xml'),\n", " PosixPath('9376583/4.xml'),\n", " PosixPath('9376583/5.xml'),\n", " PosixPath('9376583/6.xml')]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "paths = sorted(Path(\".\").glob(\"9376583/[0-9]*.xml\"))\n", "list(paths)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "407" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "changesets = []\n", "for path in paths:\n", " tree = ET.parse(path)\n", " changesets.extend(tree.findall(\"changeset\"))\n", "len(changesets)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idcreated_atcomment
406665225662019-01-22T00:40:26ZAdd house for 8 Grant Rd, Hanover NH
405665226102019-01-22T00:44:50ZAdd house for 11 Hemlock Rd, Hanover NH
404665240172019-01-22T02:34:45ZAdd Woods Lake in the High Sierra
403665243372019-01-22T02:56:14ZAdd Sawmill Lake in the High Sierra
402665428532019-01-22T16:21:11ZAdd water bodies along Sawmill pass
\n", "
" ], "text/plain": [ " id created_at comment\n", "406 66522566 2019-01-22T00:40:26Z Add house for 8 Grant Rd, Hanover NH\n", "405 66522610 2019-01-22T00:44:50Z Add house for 11 Hemlock Rd, Hanover NH\n", "404 66524017 2019-01-22T02:34:45Z Add Woods Lake in the High Sierra\n", "403 66524337 2019-01-22T02:56:14Z Add Sawmill Lake in the High Sierra\n", "402 66542853 2019-01-22T16:21:11Z Add water bodies along Sawmill pass" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def process_changeset(changeset: ET.Element) -> dict:\n", " return {\n", " \"id\": changeset.get(\"id\"),\n", " \"created_at\": changeset.get(\"created_at\"),\n", " \"comment\": changeset.find(\"tag[@k='comment']\").get(\"v\"),\n", " }\n", "\n", "changeset_df = pd.DataFrame([process_changeset(changeset) for changeset in changesets])\n", "changeset_df = changeset_df.sort_values(\"created_at\")\n", "changeset_df.head()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idcreated_atcomment
168915476422020-09-26T11:16:27ZLong Trail: journey's end
167915519752020-09-26T13:37:07ZLong Trail: canada to jay peak
\n", "
" ], "text/plain": [ " id created_at comment\n", "168 91547642 2020-09-26T11:16:27Z Long Trail: journey's end\n", "167 91551975 2020-09-26T13:37:07Z Long Trail: canada to jay peak" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "long_trail_df = changeset_df[changeset_df.comment.str.contains(\"Long Trail\", case=False)]\n", "long_trail_df.head(2)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "34" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(long_trail_df)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idcreated_atcomment
168915476422020-09-26T11:16:27ZLong Trail: journey's end
167915519752020-09-26T13:37:07ZLong Trail: canada to jay peak
166915521682020-09-26T13:42:32ZLong Trail: jay loop & jay camp
164915594512020-09-26T17:36:14ZLong Trail: Belvidere Fire Tower & side trails
163915623942020-09-26T19:49:14ZLong Trail: Johnson businesses
162915893272020-09-27T16:10:29ZLong Trail: Plot Road to Route 15 in Johnson
161915898012020-09-27T16:25:25ZLong Trail: Plot Road crossing
160915910832020-09-27T17:02:55ZLong Trail: Madonna Peak and Sterling Pond
159915914212020-09-27T17:14:39ZLong Trail: Elephant’s Head Spur
158915922392020-09-27T17:43:22ZLong Trail: Smugglers Notch to Mansfield
157915949362020-09-27T19:16:35ZLong Trail: Appalachian Gap
156915982052020-09-27T21:24:53ZLong Trail: Maine Junction to Mill River
155915988492020-09-27T22:04:03ZLong Trail: Griffith Lake area
154915989012020-09-27T22:07:43ZLong Trail: mad tom notch to bromley
153916005262020-09-28T00:07:00ZLong Trail: prospect rocks
152916016942020-09-28T01:05:42ZLong Trail: stratton pond
150916024782020-09-28T01:41:47ZLong Trail: southern terminus to Harmon Hill
148916027262020-09-28T01:53:48ZLong Trail: Glastenbury Fire Tower
146916699932020-09-29T00:00:42ZLong Trail: near Cowles Cove Shelter
145916711172020-09-29T01:17:08ZLong Trail: Camel's Hump to Bolton Mountain & Old Long Trail
144916713242020-09-29T01:30:26ZLong Trail: Puffer Shelter
143916714792020-09-29T01:41:02ZLong Trail: Mansfield Nose
142916718932020-09-29T02:02:02ZLong Trail: Belvidere Road
141917087262020-09-29T12:41:43ZLong Trail: Barnes Camp Visitor Center
140917089572020-09-29T12:46:13ZLong Trail: Barnes Camp Bridge
139917330042020-09-29T23:53:44ZLong Trail: Stratton Mountain
138917333742020-09-30T00:21:53ZLong Trail: Kid Gore Shelter
137917334922020-09-30T00:33:37ZLong Trail: alignment tweaks nearGlastenbury
135917349912020-09-30T02:20:20ZLong Trail: Melville Nauheim Shelter
134917925522020-10-01T01:21:24ZLong Trail: Little Rock Pond
133917933152020-10-01T02:11:55ZLong Trail: Bloodroot Area
125920747052020-10-07T01:50:04ZLong Trail: VT11, Corridor 7, fix overlapping ways
123920750552020-10-07T02:12:27ZLong Trail: reorder route relation, NoBo sequential
122921119122020-10-07T12:14:46ZLong Trail: relation tags as per https://wiki.openstreetmap.org/w/index.php?title=United_States/Long_distance_trails&oldid=1996282
\n", "
" ], "text/plain": [ " id created_at \\\n", "168 91547642 2020-09-26T11:16:27Z \n", "167 91551975 2020-09-26T13:37:07Z \n", "166 91552168 2020-09-26T13:42:32Z \n", "164 91559451 2020-09-26T17:36:14Z \n", "163 91562394 2020-09-26T19:49:14Z \n", "162 91589327 2020-09-27T16:10:29Z \n", "161 91589801 2020-09-27T16:25:25Z \n", "160 91591083 2020-09-27T17:02:55Z \n", "159 91591421 2020-09-27T17:14:39Z \n", "158 91592239 2020-09-27T17:43:22Z \n", "157 91594936 2020-09-27T19:16:35Z \n", "156 91598205 2020-09-27T21:24:53Z \n", "155 91598849 2020-09-27T22:04:03Z \n", "154 91598901 2020-09-27T22:07:43Z \n", "153 91600526 2020-09-28T00:07:00Z \n", "152 91601694 2020-09-28T01:05:42Z \n", "150 91602478 2020-09-28T01:41:47Z \n", "148 91602726 2020-09-28T01:53:48Z \n", "146 91669993 2020-09-29T00:00:42Z \n", "145 91671117 2020-09-29T01:17:08Z \n", "144 91671324 2020-09-29T01:30:26Z \n", "143 91671479 2020-09-29T01:41:02Z \n", "142 91671893 2020-09-29T02:02:02Z \n", "141 91708726 2020-09-29T12:41:43Z \n", "140 91708957 2020-09-29T12:46:13Z \n", "139 91733004 2020-09-29T23:53:44Z \n", "138 91733374 2020-09-30T00:21:53Z \n", "137 91733492 2020-09-30T00:33:37Z \n", "135 91734991 2020-09-30T02:20:20Z \n", "134 91792552 2020-10-01T01:21:24Z \n", "133 91793315 2020-10-01T02:11:55Z \n", "125 92074705 2020-10-07T01:50:04Z \n", "123 92075055 2020-10-07T02:12:27Z \n", "122 92111912 2020-10-07T12:14:46Z \n", "\n", " comment \n", "168 Long Trail: journey's end \n", "167 Long Trail: canada to jay peak \n", "166 Long Trail: jay loop & jay camp \n", "164 Long Trail: Belvidere Fire Tower & side trails \n", "163 Long Trail: Johnson businesses \n", "162 Long Trail: Plot Road to Route 15 in Johnson \n", "161 Long Trail: Plot Road crossing \n", "160 Long Trail: Madonna Peak and Sterling Pond \n", "159 Long Trail: Elephant’s Head Spur \n", "158 Long Trail: Smugglers Notch to Mansfield \n", "157 Long Trail: Appalachian Gap \n", "156 Long Trail: Maine Junction to Mill River \n", "155 Long Trail: Griffith Lake area \n", "154 Long Trail: mad tom notch to bromley \n", "153 Long Trail: prospect rocks \n", "152 Long Trail: stratton pond \n", "150 Long Trail: southern terminus to Harmon Hill \n", "148 Long Trail: Glastenbury Fire Tower \n", "146 Long Trail: near Cowles Cove Shelter \n", "145 Long Trail: Camel's Hump to Bolton Mountain & Old Long Trail \n", "144 Long Trail: Puffer Shelter \n", "143 Long Trail: Mansfield Nose \n", "142 Long Trail: Belvidere Road \n", "141 Long Trail: Barnes Camp Visitor Center \n", "140 Long Trail: Barnes Camp Bridge \n", "139 Long Trail: Stratton Mountain \n", "138 Long Trail: Kid Gore Shelter \n", "137 Long Trail: alignment tweaks nearGlastenbury \n", "135 Long Trail: Melville Nauheim Shelter \n", "134 Long Trail: Little Rock Pond \n", "133 Long Trail: Bloodroot Area \n", "125 Long Trail: VT11, Corridor 7, fix overlapping ways \n", "123 Long Trail: reorder route relation, NoBo sequential \n", "122 Long Trail: relation tags as per https://wiki.openstreetmap.org/w/index.php?title=United_States/Long_distance_trails&oldid=1996282 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.set_option('display.max_colwidth', None)\n", "long_trail_df" ] } ], "metadata": { "interpreter": { "hash": "2cce243c01022a98ef83c8e07ad7c254079cab9525034c4e8d957ef5fded0f1e" }, "kernelspec": { "display_name": "Python 3.9.0 64-bit ('base': conda)", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.0" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }