Skip to content

Commit 8311043

Browse files
author
Atma Mani
authored
Merge pull request Esri#465 from Esri/july02_webinar
- July 2 2019 Webinar Added.
2 parents 828c36e + d59d50d commit 8311043

30 files changed

+7658
-0
lines changed
Lines changed: 335 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# GIS Basics"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"- Authentication\n",
15+
"- Searching and Using Content\n",
16+
"- Mapping Information\n"
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
"source": [
23+
"## It Starts with an Import..."
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"#### Connecting to AGOL Anonymously"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"from arcgis.gis import GIS\n",
40+
"gis = GIS()"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"#### Supports Multiple Authentication Methods"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"- Oauth 2.0\n",
55+
"- PKI\n",
56+
"- IWA\n",
57+
"- Named User"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"gis = GIS(username='webinaruser')\n",
67+
"gis.users.me"
68+
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"**Store Credentials Using Profiles**\n",
75+
"\n",
76+
"- Store login information locally using OS credential store"
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"metadata": {},
83+
"outputs": [],
84+
"source": [
85+
"import getpass\n",
86+
"password = getpass.getpass()"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": null,
92+
"metadata": {},
93+
"outputs": [],
94+
"source": [
95+
"gis = GIS(username='webinaruser', \n",
96+
" password=password,\n",
97+
" profile='webinar_demo')"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {},
104+
"outputs": [],
105+
"source": [
106+
"del gis\n",
107+
"gis = GIS(profile='webinar_demo')\n",
108+
"gis.users.me"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": [
115+
"### GIS the Entry into WebGIS"
116+
]
117+
},
118+
{
119+
"cell_type": "markdown",
120+
"metadata": {},
121+
"source": [
122+
"- Access, add, publish and share content\n",
123+
"- Manage, modify and control your Portal/Server (administrators)\n",
124+
"- Build your digital geo-spatial community"
125+
]
126+
},
127+
{
128+
"cell_type": "markdown",
129+
"metadata": {},
130+
"source": [
131+
"## Searching for Content\n",
132+
"\n",
133+
"- Two Methods:\n",
134+
"\n",
135+
" + `search` - simple search\n",
136+
" + `advanced_search` - provides complete control on how filters, name and responses are returned\n",
137+
" "
138+
]
139+
},
140+
{
141+
"cell_type": "markdown",
142+
"metadata": {},
143+
"source": [
144+
"### Simple Search\n",
145+
"\n",
146+
"- Easy to use search interface\n",
147+
"- Provides back a list of `Item` objects\n",
148+
"- Limited to **1000** features"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": null,
154+
"metadata": {},
155+
"outputs": [],
156+
"source": [
157+
"from IPython.display import display"
158+
]
159+
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": null,
163+
"metadata": {},
164+
"outputs": [],
165+
"source": [
166+
"results = gis.content.search(\n",
167+
" query=\"United States owner:esri\",\n",
168+
" outside_org=True,\n",
169+
" item_type=\"Feature Layer\")\n",
170+
"for item in results:\n",
171+
" display(item)"
172+
]
173+
},
174+
{
175+
"cell_type": "markdown",
176+
"metadata": {},
177+
"source": [
178+
"### Advanced Search\n",
179+
"\n",
180+
"- Provides custom paging \n",
181+
"- Response is a dictionary\n",
182+
"- Results can comeback as an `Item` or `Dictionary`\n",
183+
"- Provides Search Statistics"
184+
]
185+
},
186+
{
187+
"cell_type": "code",
188+
"execution_count": null,
189+
"metadata": {},
190+
"outputs": [],
191+
"source": [
192+
"query = (\"owner:esri United States (type:(\\\"Feature Collection\\\" OR \\\"Feature \"\n",
193+
" \"Service\\\" OR \\\"Stream Service\\\" OR \\\"WFS\\\") -typekeywords:\\\"Table\\\")\")"
194+
]
195+
},
196+
{
197+
"cell_type": "code",
198+
"execution_count": null,
199+
"metadata": {},
200+
"outputs": [],
201+
"source": [
202+
"gis.content.advanced_search(query=query,\n",
203+
" return_count=True)"
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": null,
209+
"metadata": {},
210+
"outputs": [],
211+
"source": [
212+
"for result in gis.content.advanced_search(query=query,\n",
213+
" start=10)['results']:\n",
214+
" display(result)"
215+
]
216+
},
217+
{
218+
"cell_type": "markdown",
219+
"metadata": {},
220+
"source": [
221+
"## Visualizing Content"
222+
]
223+
},
224+
{
225+
"cell_type": "markdown",
226+
"metadata": {},
227+
"source": [
228+
"The `GIS` object provides a widget to visualize spatial data\n",
229+
"\n",
230+
"- Define location by:\n",
231+
" + extent\n",
232+
" + address\n",
233+
"- Set the `basemap`\n",
234+
"- Customize layers look and feel\n",
235+
"- Save it to a WebMap"
236+
]
237+
},
238+
{
239+
"cell_type": "code",
240+
"execution_count": null,
241+
"metadata": {},
242+
"outputs": [],
243+
"source": [
244+
"m = gis.map('Youngstown, PA')\n",
245+
"m.zoom = 9\n",
246+
"m"
247+
]
248+
},
249+
{
250+
"cell_type": "markdown",
251+
"metadata": {},
252+
"source": [
253+
"**Example: Looking at the Basemaps**"
254+
]
255+
},
256+
{
257+
"cell_type": "code",
258+
"execution_count": null,
259+
"metadata": {},
260+
"outputs": [],
261+
"source": [
262+
"import time\n",
263+
"for b in m.basemaps[0::2]:\n",
264+
" print(b)\n",
265+
" m.basemap = b\n",
266+
" time.sleep(2)"
267+
]
268+
},
269+
{
270+
"cell_type": "code",
271+
"execution_count": null,
272+
"metadata": {},
273+
"outputs": [],
274+
"source": [
275+
"m.basemap = 'dark-gray'"
276+
]
277+
},
278+
{
279+
"cell_type": "code",
280+
"execution_count": null,
281+
"metadata": {},
282+
"outputs": [],
283+
"source": [
284+
"water = gis.content.get(\"9dff3cf646704abd9e74265f02abeb09\")\n",
285+
"rivers = gis.content.get(\"0baca6c9ffd6499fb8e5fad50174c4e0\")"
286+
]
287+
},
288+
{
289+
"cell_type": "code",
290+
"execution_count": null,
291+
"metadata": {},
292+
"outputs": [],
293+
"source": [
294+
"m.add_layer(water)\n",
295+
"m.add_layer(rivers)"
296+
]
297+
},
298+
{
299+
"cell_type": "code",
300+
"execution_count": null,
301+
"metadata": {},
302+
"outputs": [],
303+
"source": [
304+
"webmap_item = m.save(item_properties={\n",
305+
" 'title' : \"USA Water Bodies\",\n",
306+
" 'snippet' : \"Water Bodies\",\n",
307+
" 'description' : \"Water Bodies in the USA\",\n",
308+
" 'tags' : 'water, rivers, lakes'\n",
309+
"})\n",
310+
"webmap_item"
311+
]
312+
}
313+
],
314+
"metadata": {
315+
"kernelspec": {
316+
"display_name": "Python 3",
317+
"language": "python",
318+
"name": "python3"
319+
},
320+
"language_info": {
321+
"codemirror_mode": {
322+
"name": "ipython",
323+
"version": 3
324+
},
325+
"file_extension": ".py",
326+
"mimetype": "text/x-python",
327+
"name": "python",
328+
"nbconvert_exporter": "python",
329+
"pygments_lexer": "ipython3",
330+
"version": "3.6.6"
331+
}
332+
},
333+
"nbformat": 4,
334+
"nbformat_minor": 2
335+
}

0 commit comments

Comments
 (0)