|
258 | 258 | "metadata": {},
|
259 | 259 | "outputs": [],
|
260 | 260 | "source": [
|
261 |
| - "gpd_rivers_org = gpd.read_file(\n", |
| 261 | + "gdf_rivers_org = gpd.read_file(\n", |
262 | 262 | " \"https://www.eea.europa.eu/data-and-maps/data/wise-large-rivers-and-large-lakes/\"\n",
|
263 | 263 | " + \"zipped-shapefile-with-wise-large-rivers-vector-line/zipped-shapefile-with-wise-large-rivers-vector-line/\"\n",
|
264 | 264 | " + \"at_download/file/wise_large_rivers.zip\"\n",
|
265 | 265 | ")\n",
|
266 |
| - "# gpd_rivers_org = pd.read_file(\"wise_large_rivers.zip\")\n", |
267 |
| - "gpd_rivers_org.head()" |
| 266 | + "# gdf_rivers_org = gpd.read_file(\"wise_large_rivers.zip\")" |
268 | 267 | ]
|
269 | 268 | },
|
270 | 269 | {
|
271 | 270 | "cell_type": "markdown",
|
272 | 271 | "id": "f8db1757-f80d-4cc3-b650-83109eecc390",
|
273 | 272 | "metadata": {},
|
274 | 273 | "source": [
|
275 |
| - "Have a look at the values in the geometry column. The coordinates are currently not given in the geographic coordinate reference system (longitude/latitude) and have to be converted. This can be done directly with `GeoPandas`." |
| 274 | + "Have a look at the data and especially at the values in the geometry column:" |
276 | 275 | ]
|
277 | 276 | },
|
278 | 277 | {
|
279 | 278 | "cell_type": "code",
|
280 | 279 | "execution_count": null,
|
281 |
| - "id": "cc67a58c-45f3-4819-9df4-04e5aa9d06f7", |
| 280 | + "id": "926955ee-3859-468b-9b41-0398ed6c7b99", |
282 | 281 | "metadata": {},
|
283 | 282 | "outputs": [],
|
284 | 283 | "source": [
|
285 |
| - "gpd_rivers_org.crs\n", |
286 |
| - "gpd_rivers = gpd_rivers_org.to_crs(\"EPSG:4326\")\n", |
287 |
| - "gpd_rivers.head()" |
| 284 | + "gdf_rivers_org.head()" |
| 285 | + ] |
| 286 | + }, |
| 287 | + { |
| 288 | + "cell_type": "markdown", |
| 289 | + "id": "b868d284-23ff-4607-a950-de47da71f7cd", |
| 290 | + "metadata": {}, |
| 291 | + "source": [ |
| 292 | + "The coordinates are currently not given in the geographic coordinate reference system (longitude/latitude):" |
| 293 | + ] |
| 294 | + }, |
| 295 | + { |
| 296 | + "cell_type": "code", |
| 297 | + "execution_count": null, |
| 298 | + "id": "f033930d-fe1c-4883-a27c-6a768bb29598", |
| 299 | + "metadata": {}, |
| 300 | + "outputs": [], |
| 301 | + "source": [ |
| 302 | + "gdf_rivers_org.crs" |
| 303 | + ] |
| 304 | + }, |
| 305 | + { |
| 306 | + "cell_type": "markdown", |
| 307 | + "id": "59edb4bf-9466-41a9-9cf6-f2ae3d7a5a0d", |
| 308 | + "metadata": {}, |
| 309 | + "source": [ |
| 310 | + "Thus, they have to be converted which can be done directly with `GeoPandas`." |
| 311 | + ] |
| 312 | + }, |
| 313 | + { |
| 314 | + "cell_type": "code", |
| 315 | + "execution_count": null, |
| 316 | + "id": "c6a07d4d-ec70-4624-836b-41f713218f11", |
| 317 | + "metadata": {}, |
| 318 | + "outputs": [], |
| 319 | + "source": [ |
| 320 | + "gdf_rivers = gdf_rivers_org.to_crs(\"EPSG:4326\")" |
| 321 | + ] |
| 322 | + }, |
| 323 | + { |
| 324 | + "cell_type": "markdown", |
| 325 | + "id": "cd9b9f2b-d15b-4336-b2ee-4370bb6ffb25", |
| 326 | + "metadata": {}, |
| 327 | + "source": [ |
| 328 | + "Again have a look at the coordinate system and the data:" |
| 329 | + ] |
| 330 | + }, |
| 331 | + { |
| 332 | + "cell_type": "code", |
| 333 | + "execution_count": null, |
| 334 | + "id": "06124f49-4dc7-4518-8ceb-b85257a30920", |
| 335 | + "metadata": {}, |
| 336 | + "outputs": [], |
| 337 | + "source": [ |
| 338 | + "gdf_rivers.crs" |
| 339 | + ] |
| 340 | + }, |
| 341 | + { |
| 342 | + "cell_type": "code", |
| 343 | + "execution_count": null, |
| 344 | + "id": "537e141d-6f64-4b99-9e30-75e1c217d3c5", |
| 345 | + "metadata": {}, |
| 346 | + "outputs": [], |
| 347 | + "source": [ |
| 348 | + "gdf_rivers.head()" |
288 | 349 | ]
|
289 | 350 | },
|
290 | 351 | {
|
|
314 | 375 | " frame=True,\n",
|
315 | 376 | ")\n",
|
316 | 377 | "\n",
|
317 |
| - "fig.plot(data=gpd_rivers, pen=\"0.5p,steelblue,solid\")\n", |
| 378 | + "fig.plot(data=gdf_rivers, pen=\"0.5p,steelblue,solid\")\n", |
318 | 379 | "\n",
|
319 | 380 | "fig.show(dpi=img_dpi)"
|
320 | 381 | ]
|
|
341 | 402 | "# Split the dataset into two subsets of shorter and longer rivers\n",
|
342 | 403 | "# Feel free to play around with the limit\n",
|
343 | 404 | "len_limit = 700000 # in meters\n",
|
344 |
| - "gpd_rivers_short = gpd_rivers[gpd_rivers[\"Shape_Leng\"] < len_limit]\n", |
345 |
| - "gpd_rivers_long = gpd_rivers[gpd_rivers[\"Shape_Leng\"] > len_limit]\n", |
| 405 | + "gdf_rivers_short = gdf_rivers[gdf_rivers[\"Shape_Leng\"] < len_limit]\n", |
| 406 | + "gdf_rivers_long = gdf_rivers[gdf_rivers[\"Shape_Leng\"] > len_limit]\n", |
346 | 407 | "\n",
|
347 | 408 | "\n",
|
348 | 409 | "fig = pygmt.Figure()\n",
|
|
357 | 418 | "\n",
|
358 | 419 | "# Plot the subsets differently and specify the text for the legend entries\n",
|
359 | 420 | "fig.plot(\n",
|
360 |
| - " data=gpd_rivers_short,\n", |
| 421 | + " data=gdf_rivers_short,\n", |
361 | 422 | " pen=\"0.5p,orange\",\n",
|
362 | 423 | " label=f\"shorter {len_limit} m+Hriver length+f9p\",\n",
|
363 | 424 | ")\n",
|
364 |
| - "fig.plot(data=gpd_rivers_long, pen=\"0.5p,darkred\", label=f\"longer {len_limit} m\")\n", |
| 425 | + "fig.plot(data=gdf_rivers_long, pen=\"0.5p,darkred\", label=f\"longer {len_limit} m\")\n", |
365 | 426 | "\n",
|
366 | 427 | "# Place the legend at the Top Left corner with an offset of 0.1 centimeters from the map frame\n",
|
367 | 428 | "# Add a box with semi-transparent (@30) white fill (+g) and a 0.1-points thick gray outline (+p)\n",
|
|
520 | 581 | ")\n",
|
521 | 582 | "\n",
|
522 | 583 | "pygmt.makecpt(\n",
|
523 |
| - " cmap=\"SCM/oslo\", series=[gpd_rivers.Shape_Leng.min(), 1500000], reverse=True\n", |
| 584 | + " cmap=\"SCM/oslo\", series=[gdf_rivers.Shape_Leng.min(), 1500000], reverse=True\n", |
524 | 585 | ")\n",
|
525 | 586 | "fig.colorbar(frame=[\"x+lriver length\", \"y+lm\"], position=\"+ef0.2c\")\n",
|
526 | 587 | "\n",
|
527 |
| - "for i_river in range(len(gpd_rivers)):\n", |
| 588 | + "for i_river in range(len(gdf_rivers)):\n", |
528 | 589 | " fig.plot(\n",
|
529 |
| - " data=gpd_rivers[gpd_rivers.index == i_river],\n", |
530 |
| - " zvalue=gpd_rivers.loc[i_river, \"Shape_Leng\"],\n", |
| 590 | + " data=gdf_rivers[gdf_rivers.index == i_river],\n", |
| 591 | + " zvalue=gdf_rivers.loc[i_river, \"Shape_Leng\"],\n", |
531 | 592 | " pen=\"0.5p\",\n",
|
532 | 593 | " cmap=True,\n",
|
533 | 594 | " )\n",
|
|
552 | 613 | "name": "python",
|
553 | 614 | "nbconvert_exporter": "python",
|
554 | 615 | "pygments_lexer": "ipython3",
|
555 |
| - "version": "3.12.6" |
| 616 | + "version": "3.12.7" |
556 | 617 | }
|
557 | 618 | },
|
558 | 619 | "nbformat": 4,
|
|
0 commit comments