|
17 | 17 | "2. You can \"run\" each of these cells/regions by either pressing the \"play\" button in the menu above, or by pressing CTRL+ENTER on your keyboard.\n", |
18 | 18 | "3. If you are in the \"editing\" mode where you type into a cell, pressing ESC will take you back to the mode where the arrow keys work. \n", |
19 | 19 | "\n", |
20 | | - "### Uploading the OSM history file\n", |
| 20 | + "## Getting an OSM history file\n", |
21 | 21 | "\n", |
22 | 22 | "Before we can do the rest of the steps in this notebook, you will have to upload an OSM history file that covers your region of interest. You can find the corresponding files on [Geofabrik's internal download server](https://osm-internal.download.geofabrik.de/?landing_page=true). Login with your OSM account to get to the `internal` files, and then find the page for the your region of interest. Ideally, find the smallest region that covers your area of interest to minimize the filesize you need to upload. \n", |
23 | 23 | "\n", |
24 | 24 | "**The right file**: When you've picked your region, you will likely see two similarly named files listed: `regionname-internal.osh.pbf` and `regionname-latest-internal.osm.pbf`. The file you will want to download is the `regionname-internal.osh.pbf` (i.e. the one that includes `osh` and **no `latest`**).\n", |
25 | 25 | "\n", |
26 | 26 | "Once you have downloaded your file onto your computer, you need to upload it into your container. There are a few options that you can consider, depending on how you are using this notebook:\n", |
27 | 27 | "\n", |
28 | | - "#### Uploading a file you already have downloaded onto your computer\n", |
| 28 | + "### 1. Uploading a file you already have downloaded onto your computer\n", |
29 | 29 | "\n", |
30 | 30 | "* If you've launched this notebook in _MyBinder_, you can then open up the filebrowser on the top of the left hand side (The _file_ icon, or by pressing CTRL+SHIFT+F). \n", |
31 | 31 | "* If you've launched this notebook locally, you're likely in the _notebook_ interface, switch back to the _tree_ view and upload your file there (or put it into the shared folder which is accessible by both the container and your normal operating system).\n", |
32 | 32 | "\n", |
33 | | - "#### Downloading a file directly from Geofabrik \n", |
| 33 | + "### 2. Downloading a file directly from Geofabrik \n", |
34 | 34 | "\n", |
35 | | - "This option is particularly useful if you use this notebook on MyBinder, as it allows you to directly download the OSM history file into your Binder, without having to first download it onto your computer and then re-uploading it to the Binder, speeding things up considerably. As the OSM history files are only accessible with an OSM account, you will unfortunately have to fill out the form below, including your OSM username & password. \n", |
| 35 | + "This option is particularly useful if you use this notebook on MyBinder, as it allows you to directly download the OSM history file into your Binder, without having to first download it onto your computer and then re-uploading it to the Binder, speeding things up considerably. As the OSM history files are only accessible with an OSM account, you will have to be authenticated to use this method. \n", |
| 36 | + "\n", |
| 37 | + "There are two ways of achieving this to access files directly from _Geofabrik_. \n", |
| 38 | + "\n", |
| 39 | + "#### 2.1 Option a): Using your OSM username & password.\n", |
| 40 | + "\n", |
| 41 | + "You can use your OSM username & password to authenticate, by running the cell below and then entering the form fields. \n", |
36 | 42 | "\n", |
37 | 43 | "**Note:** Your username & password will only be used to get a cookie that allows downloading the files and won't be permanently stored (and are not accessible to anyone else). If you are using _MyBinder_, your virtual machine will automatically shut down after more than 10 minutes of inactivity, destroying all data within the virtual machine in the process. If you are running this in a Docker container on your own computer the container will also destroy itself after shutting it down. \n", |
38 | 44 | "\n", |
|
41 | 47 | }, |
42 | 48 | { |
43 | 49 | "cell_type": "code", |
44 | | - "execution_count": 4, |
| 50 | + "execution_count": 6, |
45 | 51 | "id": "7d8cfd4c-913e-4983-92ef-c40567421331", |
46 | | - "metadata": { |
47 | | - "jupyter": { |
48 | | - "source_hidden": true |
49 | | - } |
50 | | - }, |
| 52 | + "metadata": {}, |
51 | 53 | "outputs": [ |
52 | 54 | { |
53 | 55 | "data": { |
54 | 56 | "application/vnd.jupyter.widget-view+json": { |
55 | | - "model_id": "0036ae1165254d019e392a3ebd9b7905", |
| 57 | + "model_id": "79eb82aff050415b9c87d9073a876a99", |
56 | 58 | "version_major": 2, |
57 | 59 | "version_minor": 0 |
58 | 60 | }, |
59 | 61 | "text/plain": [ |
60 | 62 | "VBox(children=(Text(value='', description='OSM username:', placeholder='Steve'), Text(value='', description='O…" |
61 | 63 | ] |
62 | 64 | }, |
63 | | - "execution_count": 4, |
| 65 | + "execution_count": 6, |
64 | 66 | "metadata": {}, |
65 | 67 | "output_type": "execute_result" |
66 | 68 | } |
|
128 | 130 | "!python sendfile_osm_oauth_protector/oauth_cookie_client.py -u \"{osm_user.value}\" -p \"{osm_password.value}\" -c \"https://osm-internal.download.geofabrik.de/get_cookie\" -f netscape -o geofabrik_cookie.txt;wget --max-redirect 0 --load-cookies geofabrik_cookie.txt {file_url.value}" |
129 | 131 | ] |
130 | 132 | }, |
| 133 | + { |
| 134 | + "cell_type": "markdown", |
| 135 | + "id": "78358b23-cf0b-4890-83bc-70ead669b77d", |
| 136 | + "metadata": {}, |
| 137 | + "source": [ |
| 138 | + "Once this is finished, you can move down to **Starting to make comparison images**!" |
| 139 | + ] |
| 140 | + }, |
| 141 | + { |
| 142 | + "cell_type": "markdown", |
| 143 | + "id": "66cc684e-90e9-4ccb-a851-9315aaac5362", |
| 144 | + "metadata": {}, |
| 145 | + "source": [ |
| 146 | + "#### 2.1 Option b): Using an existing Geofabrik cookie from your browser. \n", |
| 147 | + "\n", |
| 148 | + "This method allows you to paste the cookie that Geofabrik uses to check if you're allowed to download a file. As a result, **this method does not need to enter your OSM username/password**. The downside is that it's slightly more complicated, as it requires finding the cookie value in your web browser. \n", |
| 149 | + "\n", |
| 150 | + "To use this option, do the following: \n", |
| 151 | + "\n", |
| 152 | + "1. Head to the [OSM internal Geofabrik download page](https://osm-internal.download.geofabrik.de/)\n", |
| 153 | + "2. Log-in on that page with your existing OSM credentials, this will create the necessary cookie. \n", |
| 154 | + "3. Find the cookie in your web-browser: If you're using Firefox, press `F12` on your keyboard to open the web developer tools\n", |
| 155 | + "4. Go to the tab called `Storage` in the bar that opens at the bottom of your browser\n", |
| 156 | + "5. On the bottom-left, you will see `Cookies`, click on it and select the cookie that starts with `https://osm-internal.download.geofabrik.de`.\n", |
| 157 | + "6. You will see a Name/Value pair displayed, with the name reading `gf_download_oauth`. Select this cookie\n", |
| 158 | + "7. On the right-hand side you will see a `Data` option, which gives the full cookie contents. You can right-click on this and select `Copy`.\n", |
| 159 | + "\n", |
| 160 | + "You can then paste this cookie data into the form below, alongside the link to the file you want to download:" |
| 161 | + ] |
| 162 | + }, |
| 163 | + { |
| 164 | + "cell_type": "code", |
| 165 | + "execution_count": 31, |
| 166 | + "id": "e5f626cc-f267-4f19-a290-17144f1ffde9", |
| 167 | + "metadata": {}, |
| 168 | + "outputs": [ |
| 169 | + { |
| 170 | + "data": { |
| 171 | + "application/vnd.jupyter.widget-view+json": { |
| 172 | + "model_id": "1f012554f3fb458b84fa56c27973df37", |
| 173 | + "version_major": 2, |
| 174 | + "version_minor": 0 |
| 175 | + }, |
| 176 | + "text/plain": [ |
| 177 | + "VBox(children=(Text(value='', description='gf_download_oauth cookie value:', placeholder='login|2018-04-12|WVR…" |
| 178 | + ] |
| 179 | + }, |
| 180 | + "execution_count": 31, |
| 181 | + "metadata": {}, |
| 182 | + "output_type": "execute_result" |
| 183 | + } |
| 184 | + ], |
| 185 | + "source": [ |
| 186 | + "geofabrik_cookie = ('gf_download_oauth', widgets.Text(\n", |
| 187 | + " placeholder='login|2018-04-12|WVRced34c...',\n", |
| 188 | + " description='gf_download_oauth cookie value:',\n", |
| 189 | + " disabled=False))\n", |
| 190 | + "file_url = widgets.Text(\n", |
| 191 | + " placeholder='https://osm-internal.download.geofabrik.de/south-america/argentina-internal.osh.pbf',\n", |
| 192 | + " description='Link to OSM history file:',\n", |
| 193 | + " disabled=False)\n", |
| 194 | + "\n", |
| 195 | + "widgets.VBox([\n", |
| 196 | + " geofabrik_cookie[1],\n", |
| 197 | + " file_url])" |
| 198 | + ] |
| 199 | + }, |
| 200 | + { |
| 201 | + "cell_type": "markdown", |
| 202 | + "id": "55e67302-5653-4f4f-b2c5-3963379e4ecc", |
| 203 | + "metadata": {}, |
| 204 | + "source": [ |
| 205 | + "Once you have added those, run the cell below to download your file." |
| 206 | + ] |
| 207 | + }, |
| 208 | + { |
| 209 | + "cell_type": "code", |
| 210 | + "execution_count": 32, |
| 211 | + "id": "4eb7ed00-1902-4d5e-8ba3-f149ad85c61d", |
| 212 | + "metadata": {}, |
| 213 | + "outputs": [ |
| 214 | + { |
| 215 | + "name": "stdout", |
| 216 | + "output_type": "stream", |
| 217 | + "text": [ |
| 218 | + "login|2018-04-12|eRRYaHdVQwFceNZlGOUawLbKH8oR-OjHNwBmVcnkpOaJJa0-H9X6zfFgJLWrfwbGXzdyh7bNUPH1WjrvkkpWAY4kI6rSSg_A_HP2CSpAS4XEr91hLamrnPsrgbYETIUWkvKRrFzVthHkHJDALGVmd7E8fgNKe_uL9xeJaKAWU_Ydi_uu4a86xKhgkfZv1NBI_g27phWwTtvt-TE57v9Vygc_jgozXpnmL3ENny3g\n", |
| 219 | + "--2024-12-26 14:53:24-- https://osm-internal.download.geofabrik.de/europe/malta-internal.osh.pbf\n", |
| 220 | + "Resolving osm-internal.download.geofabrik.de (osm-internal.download.geofabrik.de)... 65.109.22.172, 2a01:4f9:5a:1426::2\n", |
| 221 | + "connected. to osm-internal.download.geofabrik.de (osm-internal.download.geofabrik.de)|65.109.22.172|:443... \n", |
| 222 | + "HTTP request sent, awaiting response... 200 OK\n", |
| 223 | + "Length: 18084230 (17M) [application/octet-stream]\n", |
| 224 | + "Saving to: ‘malta-internal.osh.pbf’\n", |
| 225 | + "\n", |
| 226 | + "malta-internal.osh. 100%[===================>] 17.25M 4.12MB/s in 4.2s \n", |
| 227 | + "\n", |
| 228 | + "2024-12-26 14:53:29 (4.12 MB/s) - ‘malta-internal.osh.pbf’ saved [18084230/18084230]\n", |
| 229 | + "\n" |
| 230 | + ] |
| 231 | + } |
| 232 | + ], |
| 233 | + "source": [ |
| 234 | + "cookie_name = geofabrik_cookie[0]\n", |
| 235 | + "if geofabrik_cookie[1].value.startswith(\"gf_download_oauth\"):\n", |
| 236 | + " cookie_value = geofabrik_cookie[1].value.replace('gf_download_oauth:\"','')\n", |
| 237 | + " cookie_value = cookie_value[:-1]\n", |
| 238 | + " print(cookie_value)\n", |
| 239 | + "else:\n", |
| 240 | + " cookie_value = geofabrik_cookie[1].value\n", |
| 241 | + " \n", |
| 242 | + "!wget --max-redirect 0 --header=\"Cookie: {cookie_name}={cookie_value}\" {file_url.value}" |
| 243 | + ] |
| 244 | + }, |
131 | 245 | { |
132 | 246 | "cell_type": "markdown", |
133 | 247 | "id": "bfe0b5b8-cebd-4975-8447-f2189459dbcb", |
134 | 248 | "metadata": {}, |
135 | 249 | "source": [ |
136 | | - "Once the file is completely downloaded (or if you uploaded the file using one of the other methods), you can continue with the next step below. \n", |
| 250 | + "Once the file is completely downloaded (or if you uploaded the file using one of the other methods above), you can continue with the next step below. \n", |
137 | 251 | "\n", |
138 | 252 | "## Starting to make the comparison images. \n", |
139 | 253 | "\n", |
|
144 | 258 | }, |
145 | 259 | { |
146 | 260 | "cell_type": "code", |
147 | | - "execution_count": 1, |
| 261 | + "execution_count": 13, |
148 | 262 | "id": "cf6cc023-ea39-46eb-885e-86a184dc1850", |
149 | | - "metadata": { |
150 | | - "jupyter": { |
151 | | - "source_hidden": true |
152 | | - } |
153 | | - }, |
| 263 | + "metadata": {}, |
154 | 264 | "outputs": [ |
155 | 265 | { |
156 | 266 | "data": { |
157 | 267 | "application/vnd.jupyter.widget-view+json": { |
158 | | - "model_id": "ef5e2a5f18f54653bf1e7d39e90559ac", |
| 268 | + "model_id": "2bd9d49b689145f093b8fe9445d0ac7c", |
159 | 269 | "version_major": 2, |
160 | 270 | "version_minor": 0 |
161 | 271 | }, |
162 | 272 | "text/plain": [ |
163 | | - "VBox(children=(Dropdown(description='File:', options=('external/argentina-internal.osh.pbf', 'external/argenti…" |
| 273 | + "VBox(children=(Dropdown(description='File:', options=('uruguay-internal.osh.pbf', 'external/argentina-internal…" |
164 | 274 | ] |
165 | 275 | }, |
166 | | - "execution_count": 1, |
| 276 | + "execution_count": 13, |
167 | 277 | "metadata": {}, |
168 | 278 | "output_type": "execute_result" |
169 | 279 | } |
|
0 commit comments