Skip to content

Commit c4791d0

Browse files
committed
update share item syntax
1 parent 23acc1b commit c4791d0

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

samples/04_gis_analysts_data_scientists/calculate_post_fire_landslide_risk.ipynb

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@
113113
}
114114
],
115115
"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",
117117
" item_type=\"Image Service\",\n",
118118
" 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",
120120
" item_type=\"Image Service\",\n",
121121
" outside_org=True)[0].layers[0]\n",
122122
"\n",
@@ -141,13 +141,13 @@
141141
}
142142
],
143143
"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",
145145
" item_type=\"Image Service\",\n",
146146
" 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",
148148
" item_type=\"Image Service\",\n",
149149
" 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",
151151
" item_type=\"Image Service\",\n",
152152
" outside_org=True)[0].layers[0]\n",
153153
"\n",
@@ -178,9 +178,9 @@
178178
"outputs": [],
179179
"source": [
180180
"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",
182182
"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\"])"
184184
]
185185
},
186186
{
@@ -213,10 +213,10 @@
213213
],
214214
"source": [
215215
"# 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",
220220
"map1.add_layer(infrared_before)\n",
221221
"map2.add_layer(infrared_after)\n",
222222
"box = HBox([map1, map2])\n",
@@ -290,7 +290,7 @@
290290
" 0.44, 0.66, # Moderate Severity\n",
291291
" 0.66, 2.00], # High Severity\n",
292292
" output_values=[1, 2, 3, 4, 5],\n",
293-
" astype='u8')\n",
293+
" astype=\"u8\")\n",
294294
"\n",
295295
"# Create a colormap to show reclassified NBR indices with different color\n",
296296
"burn_severity = colormap(nbr_diff_remap,\n",
@@ -468,7 +468,7 @@
468468
" 25, 35, # Steep\n",
469469
" 35, 91], # Very Steep\n",
470470
" output_values=[1, 2, 3, 4, 5],\n",
471-
" astype='u8'),\n",
471+
" astype=\"u8\"),\n",
472472
" colormap=[[1, 56, 168, 0], [2, 141, 212, 0],\n",
473473
" [3, 255, 255, 0], [4, 255, 128, 0],\n",
474474
" [5, 255, 0, 0]])\n",
@@ -550,7 +550,7 @@
550550
" output_values=[1, 3, 4, 5, 1, 3, 4, 3, 4, 2],\n",
551551
" # 1: very stable 2: stable 3: moderate\n",
552552
" # 4: unstable 5: very unstable\n",
553-
" astype='u8')"
553+
" astype=\"u8\")"
554554
]
555555
},
556556
{
@@ -608,7 +608,7 @@
608608
" colormap=[[1, 56, 168, 0], [2, 141, 212, 0],\n",
609609
" [3, 255, 255, 0], [4, 255, 128, 0],\n",
610610
" [5, 255, 0, 0]],\n",
611-
" astype='u8')"
611+
" astype=\"u8\")"
612612
]
613613
},
614614
{
@@ -633,12 +633,12 @@
633633
"source": [
634634
"# Create three maps to compare before and after imageries\n",
635635
"# 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",
642642
"map1.add_layer(infrared_before)\n",
643643
"map2.add_layer(infrared_after)\n",
644644
"map3.add_layer(landslide_risk)\n",
@@ -670,7 +670,7 @@
670670
"outputs": [],
671671
"source": [
672672
"# 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')}\")"
674674
]
675675
},
676676
{
@@ -693,7 +693,7 @@
693693
],
694694
"source": [
695695
"# Share it to the public\n",
696-
"landslide_risk_persistent.share(everyone=True, org=True)"
696+
"landslide_risk_persistent.sharing_level = \"EVERYONE\""
697697
]
698698
},
699699
{
@@ -764,14 +764,14 @@
764764
"source": [
765765
"%%time\n",
766766
"# 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",
772772
"\n",
773773
"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')}\")"
775775
]
776776
},
777777
{
@@ -807,33 +807,33 @@
807807
],
808808
"source": [
809809
"# 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",
811811
"\n",
812812
"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",
814814
"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",
817817
"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",
820820
"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",
823823
"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",
826826
"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",
829829
"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",
832832
"\n",
833833
"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.\"})"
837837
]
838838
},
839839
{

0 commit comments

Comments
 (0)