Skip to content

Commit 468b02e

Browse files
committed
Merge branch 'master' into dev_site_current
2 parents 2ea8003 + 8da74ff commit 468b02e

File tree

3 files changed

+311
-7
lines changed

3 files changed

+311
-7
lines changed

guide/03-the-gis/managing-your-gis-servers.ipynb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,9 +1602,7 @@
16021602
{
16031603
"cell_type": "code",
16041604
"execution_count": 76,
1605-
"metadata": {
1606-
"collapsed": true
1607-
},
1605+
"metadata": {},
16081606
"outputs": [],
16091607
"source": [
16101608
"from datetime import datetime\n",
@@ -1644,7 +1642,7 @@
16441642
"df.index = df['date']\n",
16451643
"df['count'] = df['count'] \n",
16461644
"\n",
1647-
"ax = df.plot(kind='bar', x=df['date'])\n",
1645+
"ax = df['count'].plot(kind='bar', x=df['date'])\n",
16481646
"ticklabels = ['']*len(df.index)\n",
16491647
"ticklabels[::4] = [item.strftime('%b %d') for item in df.index[::4]]\n",
16501648
"ax.xaxis.set_major_formatter(ticker.FixedFormatter(ticklabels))\n",
@@ -2109,7 +2107,7 @@
21092107
"name": "python",
21102108
"nbconvert_exporter": "python",
21112109
"pygments_lexer": "ipython3",
2112-
"version": "3.5.3"
2110+
"version": "3.6.6"
21132111
}
21142112
},
21152113
"nbformat": 4,
Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Explore the Population!\n",
8+
"This Dashboard uses the Geoenrichment API to alow users to pan around the world and explore the population of a selected AOI. Let's start by logging into ArcGIS Online and loading the *"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 1,
14+
"metadata": {
15+
"extensions": {
16+
"jupyter_dashboards": {
17+
"version": 1,
18+
"views": {
19+
"grid_default": {
20+
"hidden": true
21+
},
22+
"report_default": {
23+
"hidden": true
24+
}
25+
}
26+
}
27+
}
28+
},
29+
"outputs": [],
30+
"source": [
31+
"from IPython.display import display, clear_output\n",
32+
"import ipywidgets as widgets\n",
33+
"\n",
34+
"from arcgis.features import SpatialDataFrame\n",
35+
"from arcgis.geoenrichment import enrich\n",
36+
"from arcgis.raster import ImageryLayer\n",
37+
"from arcgis.geometry import Geometry\n",
38+
"from arcgis.gis import GIS\n",
39+
"\n",
40+
"gis = GIS(\"http://www.arcgis.com/home\", \"name\", \"pword\")\n",
41+
"img_svc ='https://landscape7.arcgis.com/arcgis/rest/services/World_Population_Density_Estimate_2016/ImageServer/'\n",
42+
"img_lyr = ImageryLayer(img_svc, gis=gis)"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": 2,
48+
"metadata": {
49+
"extensions": {
50+
"jupyter_dashboards": {
51+
"version": 1,
52+
"views": {
53+
"grid_default": {
54+
"col": 8,
55+
"height": 4,
56+
"hidden": false,
57+
"row": 24,
58+
"width": 4
59+
},
60+
"report_default": {}
61+
}
62+
}
63+
}
64+
},
65+
"outputs": [
66+
{
67+
"data": {
68+
"text/html": [
69+
"<style>\n",
70+
".intro {\n",
71+
" padding: 10px; \n",
72+
" color: #202020;\n",
73+
" font-family: 'Helvetica'\n",
74+
"}\n",
75+
".map {\n",
76+
" border: solid;\n",
77+
" height: 450;\n",
78+
"}\n",
79+
"</style>"
80+
],
81+
"text/plain": [
82+
"<IPython.core.display.HTML object>"
83+
]
84+
},
85+
"metadata": {},
86+
"output_type": "display_data"
87+
}
88+
],
89+
"source": [
90+
"%%html\n",
91+
"<style>\n",
92+
".intro {\n",
93+
" padding: 10px; \n",
94+
" color: #202020;\n",
95+
" font-family: 'Helvetica'\n",
96+
"}\n",
97+
".map {\n",
98+
" border: solid;\n",
99+
" height: 450;\n",
100+
"}\n",
101+
"</style>"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": 3,
107+
"metadata": {
108+
"extensions": {
109+
"jupyter_dashboards": {
110+
"version": 1,
111+
"views": {
112+
"grid_default": {
113+
"hidden": true
114+
},
115+
"report_default": {
116+
"hidden": true
117+
}
118+
}
119+
}
120+
}
121+
},
122+
"outputs": [],
123+
"source": [
124+
"# run_btn on_click\n",
125+
"def running(button_object):\n",
126+
" \n",
127+
" viz_map.clear_graphics()\n",
128+
"\n",
129+
" #print('GeoEnriched Cell Data')\n",
130+
" #print('-' * 75)\n",
131+
"\n",
132+
" the_geom = Geometry(viz_map.extent)\n",
133+
" enriched = SpatialDataFrame(enrich([the_geom], gis=gis))\n",
134+
" \n",
135+
" if 'TOTPOP' not in list(enriched):\n",
136+
" enriched_pop = -1\n",
137+
" else:\n",
138+
" enriched_pop = enriched.TOTPOP[0]\n",
139+
" \n",
140+
" samples = img_lyr.get_samples(the_geom.project_as(4326))# sample_count=img_lyr.properties.maxImageHeight)\n",
141+
" sample_sum = sum([float(sample['value']) for sample in samples])\n",
142+
" \n",
143+
" print('GeoEnrichment Population Results: {}'.format(enriched_pop))\n",
144+
" #print('the Geom: {}'.format(the_geom))\n",
145+
" #print('Sample Count: {}'.format(img_lyr.properties.maxImageHeight))\n",
146+
" #print('Image Server Results: {}'.format(sample_sum))\n",
147+
" \n",
148+
" title = 'GeoEnriched Cell'\n",
149+
"\n",
150+
" for feature in enriched.to_featureset():\n",
151+
" \n",
152+
" # Expand Attributes With New Lines\n",
153+
" content = \"{}\".format(\n",
154+
" '<br/>'.join(['%s: %s' % (key.upper(), value) for (key, value) in feature.attributes.items()])\n",
155+
" )\n",
156+
" \n",
157+
" # Add Cell to Map\n",
158+
" viz_map.draw(feature.geometry, popup={'title': title, 'content': content})\n",
159+
"\n",
160+
" #print('-' * 75)"
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": 4,
166+
"metadata": {
167+
"extensions": {
168+
"jupyter_dashboards": {
169+
"version": 1,
170+
"views": {
171+
"grid_default": {
172+
"col": 0,
173+
"height": 24,
174+
"hidden": false,
175+
"row": 0,
176+
"width": null
177+
},
178+
"report_default": {
179+
"hidden": false
180+
}
181+
}
182+
}
183+
},
184+
"scrolled": false
185+
},
186+
"outputs": [
187+
{
188+
"data": {
189+
"application/vnd.jupyter.widget-view+json": {
190+
"model_id": "066baf6fe6154fa4a77ca91cb6ee1ab4",
191+
"version_major": 2,
192+
"version_minor": 0
193+
},
194+
"text/plain": [
195+
"MapView(basemaps=['dark-gray', 'dark-gray-vector', 'gray', 'gray-vector', 'hybrid', 'national-geographic', 'oc…"
196+
]
197+
},
198+
"metadata": {},
199+
"output_type": "display_data"
200+
},
201+
{
202+
"data": {
203+
"application/vnd.jupyter.widget-view+json": {
204+
"model_id": "1e9068b1e8bd4d8d975bc837a6453846",
205+
"version_major": 2,
206+
"version_minor": 0
207+
},
208+
"text/plain": [
209+
"HBox(children=(Button(button_style='success', description='Fetch Extent', layout=Layout(justify_content='cente…"
210+
]
211+
},
212+
"metadata": {},
213+
"output_type": "display_data"
214+
},
215+
{
216+
"name": "stdout",
217+
"output_type": "stream",
218+
"text": [
219+
"GeoEnrichment Population Results: 1146296\n",
220+
"GeoEnrichment Population Results: 321066\n"
221+
]
222+
}
223+
],
224+
"source": [
225+
"# Create & Display Map\n",
226+
"viz_map = gis.map('St Louis')\n",
227+
"viz_map.add_layer(img_lyr)\n",
228+
"display(viz_map)\n",
229+
"\n",
230+
"# Create Submit Button & Set on_click\n",
231+
"run_btn = widgets.Button(\n",
232+
" description='Fetch Extent',\n",
233+
" button_style='success',\n",
234+
" tooltip='Collect GeoEnrichment for Extent',\n",
235+
" layout=widgets.Layout(justify_content='center', margin='0px 0px 0px 10px')\n",
236+
")\n",
237+
"run_btn.on_click(running)\n",
238+
"\n",
239+
"# Handle Widget Layout\n",
240+
"params = widgets.HBox(\n",
241+
" [run_btn], \n",
242+
" layout=widgets.Layout(justify_content='center', margin='10px')\n",
243+
")\n",
244+
"display(params)"
245+
]
246+
},
247+
{
248+
"cell_type": "code",
249+
"execution_count": null,
250+
"metadata": {
251+
"extensions": {
252+
"jupyter_dashboards": {
253+
"version": 1,
254+
"views": {
255+
"grid_default": {},
256+
"report_default": {}
257+
}
258+
}
259+
}
260+
},
261+
"outputs": [],
262+
"source": []
263+
}
264+
],
265+
"metadata": {
266+
"extensions": {
267+
"jupyter_dashboards": {
268+
"activeView": "grid_default",
269+
"version": 1,
270+
"views": {
271+
"grid_default": {
272+
"cellMargin": 10,
273+
"defaultCellHeight": 20,
274+
"maxColumns": 12,
275+
"name": "grid",
276+
"type": "grid"
277+
},
278+
"report_default": {
279+
"name": "report",
280+
"type": "report"
281+
}
282+
}
283+
}
284+
},
285+
"kernelspec": {
286+
"display_name": "Python 3",
287+
"language": "python",
288+
"name": "python3"
289+
},
290+
"language_info": {
291+
"codemirror_mode": {
292+
"name": "ipython",
293+
"version": 3
294+
},
295+
"file_extension": ".py",
296+
"mimetype": "text/x-python",
297+
"name": "python",
298+
"nbconvert_exporter": "python",
299+
"pygments_lexer": "ipython3",
300+
"version": "3.6.5"
301+
}
302+
},
303+
"nbformat": 4,
304+
"nbformat_minor": 2
305+
}

talks/uc2018/IntegratingMLandDeepLearning/1_TensorFlow/3 - City Detection.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@
444444
"\n",
445445
" for iteration in range(1000):\n",
446446
" # TrafficLand API source JSON\n",
447-
" source_json = r\"http://api.trafficland.com/v1.5/json/video_feeds?system=ddot&key=1594c8892d7fbd18181a8a6a44958b28\"\n",
447+
" trafficland_API_key = os.environ['TRAFFICLAND_API_KEY'] # \n",
448+
" source_json = r\"http://api.trafficland.com/v1.5/json/video_feeds?system=ddot&key={0}\".format(trafficland_API_key)\n",
448449
" df = pd.read_json(source_json)\n",
449450
" ddot_df = df.loc[df.provider == 'DDOT']\n",
450451
" \n",
@@ -1590,7 +1591,7 @@
15901591
"name": "python",
15911592
"nbconvert_exporter": "python",
15921593
"pygments_lexer": "ipython3",
1593-
"version": "3.6.1"
1594+
"version": "3.6.6"
15941595
}
15951596
},
15961597
"nbformat": 4,

0 commit comments

Comments
 (0)