|
51 | 51 | }, |
52 | 52 | "outputs": [], |
53 | 53 | "source": [ |
| 54 | + "%matplotlib inline\n", |
54 | 55 | "import numpy as np\n", |
55 | 56 | "import pandas as pd\n", |
56 | 57 | "import xarray as xr\n", |
|
172 | 173 | "name": "stdout", |
173 | 174 | "output_type": "stream", |
174 | 175 | "text": [ |
175 | | - "Slope range: 0.0° - 0.0°\n" |
| 176 | + "Slope range: 0.0\u00b0 - 0.0\u00b0\n" |
176 | 177 | ] |
177 | 178 | } |
178 | 179 | ], |
|
181 | 182 | "slope_agg = terrain.xrs.slope()\n", |
182 | 183 | "slope_agg.name = \"Slope\"\n", |
183 | 184 | "\n", |
184 | | - "print(f\"Slope range: {float(slope_agg.min()):.1f}° - {float(slope_agg.max()):.1f}°\")" |
| 185 | + "print(f\"Slope range: {float(slope_agg.min()):.1f}\u00b0 - {float(slope_agg.max()):.1f}\u00b0\")" |
185 | 186 | ] |
186 | 187 | }, |
187 | 188 | { |
|
357 | 358 | " Peaks: 2001m - 2014m\n", |
358 | 359 | "\n", |
359 | 360 | "Slope classes:\n", |
360 | | - " Flat: 0.0° - 0.0°\n", |
361 | | - " Gentle: 0.0° - 0.0°\n", |
362 | | - " Moderate: 0.0° - 0.0°\n", |
363 | | - " Steep: 0.0° - 0.0°\n", |
364 | | - " Very Steep: 0.0° - 0.0°\n" |
| 361 | + " Flat: 0.0\u00b0 - 0.0\u00b0\n", |
| 362 | + " Gentle: 0.0\u00b0 - 0.0\u00b0\n", |
| 363 | + " Moderate: 0.0\u00b0 - 0.0\u00b0\n", |
| 364 | + " Steep: 0.0\u00b0 - 0.0\u00b0\n", |
| 365 | + " Very Steep: 0.0\u00b0 - 0.0\u00b0\n" |
365 | 366 | ] |
366 | 367 | } |
367 | 368 | ], |
|
371 | 372 | "slope_names = [\"Flat\", \"Gentle\", \"Moderate\", \"Steep\", \"Very Steep\"]\n", |
372 | 373 | "\n", |
373 | 374 | "elev_labels = bin_ranges(elevation_zones, terrain, unit='m', decimals=0)\n", |
374 | | - "slope_labels = bin_ranges(slope_classes, slope_agg, unit='°', decimals=1)\n", |
| 375 | + "slope_labels = bin_ranges(slope_classes, slope_agg, unit='\u00b0', decimals=1)\n", |
375 | 376 | "\n", |
376 | 377 | "print(\"Elevation zones:\")\n", |
377 | 378 | "for name, label in zip(zone_names, elev_labels):\n", |
|
426 | 427 | " <thead>\n", |
427 | 428 | " <tr style=\"text-align: right;\">\n", |
428 | 429 | " <th></th>\n", |
429 | | - " <th>Flat\\n(0.0° - 0.0°)</th>\n", |
430 | | - " <th>Gentle\\n(0.0° - 0.0°)</th>\n", |
431 | | - " <th>Moderate\\n(0.0° - 0.0°)</th>\n", |
432 | | - " <th>Steep\\n(0.0° - 0.0°)</th>\n", |
433 | | - " <th>Very Steep\\n(0.0° - 0.0°)</th>\n", |
| 430 | + " <th>Flat\\n(0.0\u00b0 - 0.0\u00b0)</th>\n", |
| 431 | + " <th>Gentle\\n(0.0\u00b0 - 0.0\u00b0)</th>\n", |
| 432 | + " <th>Moderate\\n(0.0\u00b0 - 0.0\u00b0)</th>\n", |
| 433 | + " <th>Steep\\n(0.0\u00b0 - 0.0\u00b0)</th>\n", |
| 434 | + " <th>Very Steep\\n(0.0\u00b0 - 0.0\u00b0)</th>\n", |
434 | 435 | " </tr>\n", |
435 | 436 | " <tr>\n", |
436 | 437 | " <th>Elevation Zone</th>\n", |
|
487 | 488 | "</div>" |
488 | 489 | ], |
489 | 490 | "text/plain": [ |
490 | | - " Flat\\n(0.0° - 0.0°) Gentle\\n(0.0° - 0.0°) \\\n", |
| 491 | + " Flat\\n(0.0\u00b0 - 0.0\u00b0) Gentle\\n(0.0\u00b0 - 0.0\u00b0) \\\n", |
491 | 492 | "Elevation Zone \n", |
492 | 493 | "Valley\\n(1952m - 1998m) 0.160460 2.379629 \n", |
493 | 494 | "Lowlands\\n(1998m - 2000m) 4.109002 30.917339 \n", |
494 | 495 | "Foothills\\n(2000m - 2000m) 85.650793 14.349207 \n", |
495 | 496 | "Mountains\\n(2000m - 2001m) 9.803059 48.124300 \n", |
496 | 497 | "Peaks\\n(2001m - 2014m) 0.298084 4.136447 \n", |
497 | 498 | "\n", |
498 | | - " Moderate\\n(0.0° - 0.0°) Steep\\n(0.0° - 0.0°) \\\n", |
| 499 | + " Moderate\\n(0.0\u00b0 - 0.0\u00b0) Steep\\n(0.0\u00b0 - 0.0\u00b0) \\\n", |
499 | 500 | "Elevation Zone \n", |
500 | 501 | "Valley\\n(1952m - 1998m) 10.866168 28.294407 \n", |
501 | 502 | "Lowlands\\n(1998m - 2000m) 39.824184 22.381570 \n", |
502 | 503 | "Foothills\\n(2000m - 2000m) 0.000000 0.000000 \n", |
503 | 504 | "Mountains\\n(2000m - 2001m) 31.051921 10.701385 \n", |
504 | 505 | "Peaks\\n(2001m - 2014m) 18.181055 38.655471 \n", |
505 | 506 | "\n", |
506 | | - " Very Steep\\n(0.0° - 0.0°) \n", |
| 507 | + " Very Steep\\n(0.0\u00b0 - 0.0\u00b0) \n", |
507 | 508 | "Elevation Zone \n", |
508 | 509 | "Valley\\n(1952m - 1998m) 58.299336 \n", |
509 | 510 | "Lowlands\\n(1998m - 2000m) 2.767906 \n", |
|
621 | 622 | " <thead>\n", |
622 | 623 | " <tr style=\"text-align: right;\">\n", |
623 | 624 | " <th></th>\n", |
624 | | - " <th>Mean Slope (°)</th>\n", |
625 | | - " <th>Std Dev (°)</th>\n", |
| 625 | + " <th>Mean Slope (\u00b0)</th>\n", |
| 626 | + " <th>Std Dev (\u00b0)</th>\n", |
626 | 627 | " </tr>\n", |
627 | 628 | " <tr>\n", |
628 | 629 | " <th>Elevation Zone</th>\n", |
|
661 | 662 | "</div>" |
662 | 663 | ], |
663 | 664 | "text/plain": [ |
664 | | - " Mean Slope (°) Std Dev (°)\n", |
| 665 | + " Mean Slope (\u00b0) Std Dev (\u00b0)\n", |
665 | 666 | "Elevation Zone \n", |
666 | 667 | "Valley 0.000198 0.000183\n", |
667 | 668 | "Lowlands 0.000044 0.000032\n", |
|
680 | 681 | "mean_slope_by_elev = slope_agg.xrs.zonal_stats(elevation_zones, stats_funcs=['mean', 'std'])\n", |
681 | 682 | "mean_slope_by_elev['Elevation Zone'] = zone_names\n", |
682 | 683 | "mean_slope_by_elev = mean_slope_by_elev[['Elevation Zone', 'mean', 'std']]\n", |
683 | | - "mean_slope_by_elev.columns = ['Elevation Zone', 'Mean Slope (°)', 'Std Dev (°)']\n", |
| 684 | + "mean_slope_by_elev.columns = ['Elevation Zone', 'Mean Slope (\u00b0)', 'Std Dev (\u00b0)']\n", |
684 | 685 | "mean_slope_by_elev.set_index('Elevation Zone', inplace=True)\n", |
685 | 686 | "\n", |
686 | 687 | "mean_slope_by_elev" |
|
712 | 713 | ], |
713 | 714 | "source": [ |
714 | 715 | "fig, ax = plt.subplots(figsize=(10, 5))\n", |
715 | | - "mean_slope_by_elev['Mean Slope (°)'].plot(\n", |
| 716 | + "mean_slope_by_elev['Mean Slope (\u00b0)'].plot(\n", |
716 | 717 | " kind=\"bar\", ax=ax, color=\"orangered\",\n", |
717 | | - " yerr=mean_slope_by_elev['Std Dev (°)'], capsize=5)\n", |
| 718 | + " yerr=mean_slope_by_elev['Std Dev (\u00b0)'], capsize=5)\n", |
718 | 719 | "ax.set_xlabel(\"Elevation Zone\")\n", |
719 | 720 | "ax.set_ylabel(\"Mean Slope (degrees)\")\n", |
720 | 721 | "ax.set_title(\"Mean terrain steepness by elevation zone\")\n", |
|
0 commit comments