|
113 | 113 | }
|
114 | 114 | ],
|
115 | 115 | "source": [
|
116 |
| - "before_l8 = gis.content.search('title:Before_L8 owner:api_data_owner',\n", |
| 116 | + "before_l8 = gis.content.search(\"title:Before_L8 owner:api_data_owner\",\n", |
117 | 117 | " item_type=\"Image Service\",\n",
|
118 | 118 | " outside_org=True)[0].layers[0]\n",
|
119 |
| - "after_l8 = gis.content.search('title:After_L8 owner:api_data_owner',\n", |
| 119 | + "after_l8 = gis.content.search(\"title:After_L8 owner:api_data_owner\",\n", |
120 | 120 | " item_type=\"Image Service\",\n",
|
121 | 121 | " outside_org=True)[0].layers[0]\n",
|
122 | 122 | "\n",
|
|
141 | 141 | }
|
142 | 142 | ],
|
143 | 143 | "source": [
|
144 |
| - "dem = gis.content.search('title:Sonoma_DEM owner:api_data_owner',\n", |
| 144 | + "dem = gis.content.search(\"title:Sonoma_DEM owner:api_data_owner\",\n", |
145 | 145 | " item_type=\"Image Service\",\n",
|
146 | 146 | " outside_org=True)[0].layers[0]\n",
|
147 |
| - "nlcd = gis.content.search('title:Sonoma_NLCD2011 owner:api_data_owner',\n", |
| 147 | + "nlcd = gis.content.search(\"title:Sonoma_NLCD2011 owner:api_data_owner\",\n", |
148 | 148 | " item_type=\"Image Service\",\n",
|
149 | 149 | " outside_org=True)[0].layers[0]\n",
|
150 |
| - "basins = gis.content.search('title:Sonoma_Basins owner:api_data_owner',\n", |
| 150 | + "basins = gis.content.search(\"title:Sonoma_Basins owner:api_data_owner\",\n", |
151 | 151 | " item_type=\"Image Service\",\n",
|
152 | 152 | " outside_org=True)[0].layers[0]\n",
|
153 | 153 | "\n",
|
|
178 | 178 | "outputs": [],
|
179 | 179 | "source": [
|
180 | 180 | "infrared_before = extract_band(before_l8,\n",
|
181 |
| - " band_names=['sr_band5', 'sr_band3', 'sr_band2'])\n", |
| 181 | + " band_names=[\"sr_band5\", \"sr_band3\", \"sr_band2\"])\n", |
182 | 182 | "infrared_after = extract_band(after_l8,\n",
|
183 |
| - " band_names=['sr_band5', 'sr_band3', 'sr_band2'])" |
| 183 | + " band_names=[\"sr_band5\", \"sr_band3\", \"sr_band2\"])" |
184 | 184 | ]
|
185 | 185 | },
|
186 | 186 | {
|
|
213 | 213 | ],
|
214 | 214 | "source": [
|
215 | 215 | "# Create two maps to compare before and after imageries side by side\n",
|
216 |
| - "map1 = gis.map(location='-122.58, 38.45', zoomlevel=10)\n", |
217 |
| - "map2 = gis.map(location='-122.58, 38.45', zoomlevel=10)\n", |
218 |
| - "map1.layout = Layout(flex='1 1', height='500px', padding='10px')\n", |
219 |
| - "map2.layout = Layout(flex='1 1', height='500px', padding='10px')\n", |
| 216 | + "map1 = gis.map(location=\"-122.58, 38.45\", zoomlevel=10)\n", |
| 217 | + "map2 = gis.map(location=\"-122.58, 38.45\", zoomlevel=10)\n", |
| 218 | + "map1.layout = Layout(flex=\"1 1\", height=\"500px\", padding=\"10px\")\n", |
| 219 | + "map2.layout = Layout(flex=\"1 1\", height=\"500px\", padding=\"10px\")\n", |
220 | 220 | "map1.add_layer(infrared_before)\n",
|
221 | 221 | "map2.add_layer(infrared_after)\n",
|
222 | 222 | "box = HBox([map1, map2])\n",
|
|
290 | 290 | " 0.44, 0.66, # Moderate Severity\n",
|
291 | 291 | " 0.66, 2.00], # High Severity\n",
|
292 | 292 | " output_values=[1, 2, 3, 4, 5],\n",
|
293 |
| - " astype='u8')\n", |
| 293 | + " astype=\"u8\")\n", |
294 | 294 | "\n",
|
295 | 295 | "# Create a colormap to show reclassified NBR indices with different color\n",
|
296 | 296 | "burn_severity = colormap(nbr_diff_remap,\n",
|
|
468 | 468 | " 25, 35, # Steep\n",
|
469 | 469 | " 35, 91], # Very Steep\n",
|
470 | 470 | " output_values=[1, 2, 3, 4, 5],\n",
|
471 |
| - " astype='u8'),\n", |
| 471 | + " astype=\"u8\"),\n", |
472 | 472 | " colormap=[[1, 56, 168, 0], [2, 141, 212, 0],\n",
|
473 | 473 | " [3, 255, 255, 0], [4, 255, 128, 0],\n",
|
474 | 474 | " [5, 255, 0, 0]])\n",
|
|
550 | 550 | " output_values=[1, 3, 4, 5, 1, 3, 4, 3, 4, 2],\n",
|
551 | 551 | " # 1: very stable 2: stable 3: moderate\n",
|
552 | 552 | " # 4: unstable 5: very unstable\n",
|
553 |
| - " astype='u8')" |
| 553 | + " astype=\"u8\")" |
554 | 554 | ]
|
555 | 555 | },
|
556 | 556 | {
|
|
608 | 608 | " colormap=[[1, 56, 168, 0], [2, 141, 212, 0],\n",
|
609 | 609 | " [3, 255, 255, 0], [4, 255, 128, 0],\n",
|
610 | 610 | " [5, 255, 0, 0]],\n",
|
611 |
| - " astype='u8')" |
| 611 | + " astype=\"u8\")" |
612 | 612 | ]
|
613 | 613 | },
|
614 | 614 | {
|
|
633 | 633 | "source": [
|
634 | 634 | "# Create three maps to compare before and after imageries\n",
|
635 | 635 | "# and the landslide risk map side by side\n",
|
636 |
| - "map1 = gis.map(location='-122.58, 38.45', zoomlevel=15)\n", |
637 |
| - "map2 = gis.map(location='-122.58, 38.45', zoomlevel=15)\n", |
638 |
| - "map3 = gis.map(location='-122.58, 38.45', zoomlevel=15)\n", |
639 |
| - "map1.layout = Layout(flex='1 1', height='500px', padding='5px')\n", |
640 |
| - "map2.layout = Layout(flex='1 1', height='500px', padding='5px')\n", |
641 |
| - "map3.layout = Layout(flex='1 1', height='500px', padding='5px')\n", |
| 636 | + "map1 = gis.map(location=\"-122.58, 38.45\", zoomlevel=15)\n", |
| 637 | + "map2 = gis.map(location=\"-122.58, 38.45\", zoomlevel=15)\n", |
| 638 | + "map3 = gis.map(location=\"-122.58, 38.45\", zoomlevel=15)\n", |
| 639 | + "map1.layout = Layout(flex=\"1 1\", height=\"500px\", padding=\"5px\")\n", |
| 640 | + "map2.layout = Layout(flex=\"1 1\", height=\"500px\", padding=\"5px\")\n", |
| 641 | + "map3.layout = Layout(flex=\"1 1\", height=\"500px\", padding=\"5px\")\n", |
642 | 642 | "map1.add_layer(infrared_before)\n",
|
643 | 643 | "map2.add_layer(infrared_after)\n",
|
644 | 644 | "map3.add_layer(landslide_risk)\n",
|
|
670 | 670 | "outputs": [],
|
671 | 671 | "source": [
|
672 | 672 | "# Save the result as an image service\n",
|
673 |
| - "landslide_risk_persistent = landslide_risk.save(\"Sonoma_Landslide_Risk\")" |
| 673 | + "landslide_risk_persistent = landslide_risk.save(f\"Sonoma_Landslide_Risk_{dt.now().strftime('%Y%m%d%H%M%S')}\")" |
674 | 674 | ]
|
675 | 675 | },
|
676 | 676 | {
|
|
693 | 693 | ],
|
694 | 694 | "source": [
|
695 | 695 | "# Share it to the public\n",
|
696 |
| - "landslide_risk_persistent.share(everyone=True, org=True)" |
| 696 | + "landslide_risk_persistent.sharing_level = \"EVERYONE\"" |
697 | 697 | ]
|
698 | 698 | },
|
699 | 699 | {
|
|
764 | 764 | "source": [
|
765 | 765 | "%%time\n",
|
766 | 766 | "# Run global raster function and generate a persistent result in portal\n",
|
767 |
| - "landslide_risk_per_basin = gbl.zonal_statistics(in_zone_data = basins, \n", |
768 |
| - " zone_field='Value', \n", |
769 |
| - " in_value_raster=landslide_risk, \n", |
770 |
| - " ignore_nodata=True, \n", |
771 |
| - " statistics_type='MEAN')\n", |
| 767 | + "landslide_risk_per_basin = gbl.zonal_statistics(in_zone_data = basins,\n", |
| 768 | + " zone_field=\"Value\",\n", |
| 769 | + " in_value_raster=landslide_risk,\n", |
| 770 | + " ignore_nodata=True,\n", |
| 771 | + " statistics_type=\"MEAN\")\n", |
772 | 772 | "\n",
|
773 | 773 | "landslide_risk_per_basin_saved = landslide_risk_per_basin.save(\n",
|
774 |
| - " \"Landslide_Risk_Per_Basin\")" |
| 774 | + " f\"Landslide_Risk_Per_Basin_{dt.now().strftime('%Y%m%d%H%M%S')}\")" |
775 | 775 | ]
|
776 | 776 | },
|
777 | 777 | {
|
|
807 | 807 | ],
|
808 | 808 | "source": [
|
809 | 809 | "# Save the final result as a web map\n",
|
810 |
| - "landslide_by_basin_map = gis.map('-122.58, 38.45', 10)\n", |
| 810 | + "landslide_by_basin_map = gis.map(\"-122.58, 38.45\", 10)\n", |
811 | 811 | "\n",
|
812 | 812 | "landslide_by_basin_map.add_layer(landslide_risk_per_basin_saved,\n",
|
813 |
| - " options={'title': 'Landslide risk aggregated per basin'})\n", |
| 813 | + " options={\"title\": \"Landslide risk aggregated per basin\"})\n", |
814 | 814 | "landslide_by_basin_map.add_layer(landslide_risk,\n",
|
815 |
| - " options={'title': 'Landslide risk',\n", |
816 |
| - " 'visibility': False})\n", |
| 815 | + " options={\"title\": \"Landslide risk\",\n", |
| 816 | + " \"visibility\": False})\n", |
817 | 817 | "landslide_by_basin_map.add_layer(infrared_before,\n",
|
818 |
| - " options={'title': 'Pre fire satellite imagery',\n", |
819 |
| - " 'visibility': False})\n", |
| 818 | + " options={\"title\": \"Pre fire satellite imagery\",\n", |
| 819 | + " \"visibility\": False})\n", |
820 | 820 | "landslide_by_basin_map.add_layer(infrared_after,\n",
|
821 |
| - " options={'title': 'Post fire satellite imagery',\n", |
822 |
| - " 'visibility': False})\n", |
| 821 | + " options={\"title\": \"Post fire satellite imagery\",\n", |
| 822 | + " \"visibility\": False})\n", |
823 | 823 | "landslide_by_basin_map.add_layer(dem,\n",
|
824 |
| - " options={'title': 'Elevation layer used to derive slope',\n", |
825 |
| - " 'visibility': False})\n", |
| 824 | + " options={\"title\": \"Elevation layer used to derive slope\",\n", |
| 825 | + " \"visibility\": False})\n", |
826 | 826 | "landslide_by_basin_map.add_layer(nlcd,\n",
|
827 |
| - " options={'title': 'National LandCover Dataset',\n", |
828 |
| - " 'visibility': False})\n", |
| 827 | + " options={\"title\": \"National LandCover Dataset\",\n", |
| 828 | + " \"visibility\": False})\n", |
829 | 829 | "landslide_by_basin_map.add_layer(basins,\n",
|
830 |
| - " options={'title': 'Watershed basins',\n", |
831 |
| - " 'visibility': False})\n", |
| 830 | + " options={\"title\": \"Watershed basins\",\n", |
| 831 | + " \"visibility\": False})\n", |
832 | 832 | "\n",
|
833 | 833 | "landslide_by_basin_map.add_layer(infrared_after)\n",
|
834 |
| - "landslide_by_basin_map.save({'title': 'Landslide risk map',\n", |
835 |
| - " 'tags': ['landslide', 'analysis', 'forest fire'],\n", |
836 |
| - " 'snippet': 'Landslide risk map per basin.'})" |
| 834 | + "landslide_by_basin_map.save({\"title\": f\"Landslide risk map {dt.now().strftime('%Y%m%d%H%M%S')}\",\n", |
| 835 | + " \"tags\": [\"landslide\", \"analysis\", \"forest fire\"],\n", |
| 836 | + " \"snippet\": \"Landslide risk map per basin.\"})" |
837 | 837 | ]
|
838 | 838 | },
|
839 | 839 | {
|
|
0 commit comments