forked from Esri/arcgis-python-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Esri#465 from Esri/july02_webinar
- July 2 2019 Webinar Added.
- Loading branch information
Showing
30 changed files
with
7,658 additions
and
0 deletions.
There are no files selected for viewing
335 changes: 335 additions & 0 deletions
335
talks/GeoDevWebinar_July02_2019/01-GIS_DEMO/01 - GIS Basics.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,335 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# GIS Basics" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"- Authentication\n", | ||
"- Searching and Using Content\n", | ||
"- Mapping Information\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## It Starts with an Import..." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Connecting to AGOL Anonymously" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from arcgis.gis import GIS\n", | ||
"gis = GIS()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Supports Multiple Authentication Methods" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"- Oauth 2.0\n", | ||
"- PKI\n", | ||
"- IWA\n", | ||
"- Named User" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"gis = GIS(username='webinaruser')\n", | ||
"gis.users.me" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"**Store Credentials Using Profiles**\n", | ||
"\n", | ||
"- Store login information locally using OS credential store" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import getpass\n", | ||
"password = getpass.getpass()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"gis = GIS(username='webinaruser', \n", | ||
" password=password,\n", | ||
" profile='webinar_demo')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"del gis\n", | ||
"gis = GIS(profile='webinar_demo')\n", | ||
"gis.users.me" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### GIS the Entry into WebGIS" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"- Access, add, publish and share content\n", | ||
"- Manage, modify and control your Portal/Server (administrators)\n", | ||
"- Build your digital geo-spatial community" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Searching for Content\n", | ||
"\n", | ||
"- Two Methods:\n", | ||
"\n", | ||
" + `search` - simple search\n", | ||
" + `advanced_search` - provides complete control on how filters, name and responses are returned\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Simple Search\n", | ||
"\n", | ||
"- Easy to use search interface\n", | ||
"- Provides back a list of `Item` objects\n", | ||
"- Limited to **1000** features" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from IPython.display import display" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"results = gis.content.search(\n", | ||
" query=\"United States owner:esri\",\n", | ||
" outside_org=True,\n", | ||
" item_type=\"Feature Layer\")\n", | ||
"for item in results:\n", | ||
" display(item)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Advanced Search\n", | ||
"\n", | ||
"- Provides custom paging \n", | ||
"- Response is a dictionary\n", | ||
"- Results can comeback as an `Item` or `Dictionary`\n", | ||
"- Provides Search Statistics" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"query = (\"owner:esri United States (type:(\\\"Feature Collection\\\" OR \\\"Feature \"\n", | ||
" \"Service\\\" OR \\\"Stream Service\\\" OR \\\"WFS\\\") -typekeywords:\\\"Table\\\")\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"gis.content.advanced_search(query=query,\n", | ||
" return_count=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for result in gis.content.advanced_search(query=query,\n", | ||
" start=10)['results']:\n", | ||
" display(result)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Visualizing Content" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The `GIS` object provides a widget to visualize spatial data\n", | ||
"\n", | ||
"- Define location by:\n", | ||
" + extent\n", | ||
" + address\n", | ||
"- Set the `basemap`\n", | ||
"- Customize layers look and feel\n", | ||
"- Save it to a WebMap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m = gis.map('Youngstown, PA')\n", | ||
"m.zoom = 9\n", | ||
"m" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"**Example: Looking at the Basemaps**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import time\n", | ||
"for b in m.basemaps[0::2]:\n", | ||
" print(b)\n", | ||
" m.basemap = b\n", | ||
" time.sleep(2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m.basemap = 'dark-gray'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"water = gis.content.get(\"9dff3cf646704abd9e74265f02abeb09\")\n", | ||
"rivers = gis.content.get(\"0baca6c9ffd6499fb8e5fad50174c4e0\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m.add_layer(water)\n", | ||
"m.add_layer(rivers)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"webmap_item = m.save(item_properties={\n", | ||
" 'title' : \"USA Water Bodies\",\n", | ||
" 'snippet' : \"Water Bodies\",\n", | ||
" 'description' : \"Water Bodies in the USA\",\n", | ||
" 'tags' : 'water, rivers, lakes'\n", | ||
"})\n", | ||
"webmap_item" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.