Skip to content

Commit 0d01007

Browse files
author
Atma Mani
committed
Merge branch 'Yongyao-yong9856-1871'
2 parents bfa4187 + ce7edcd commit 0d01007

File tree

7 files changed

+407
-235
lines changed

7 files changed

+407
-235
lines changed

labs/create_data.ipynb

Lines changed: 44 additions & 144 deletions
Large diffs are not rendered by default.

labs/data/LAHubDatasets.zip

1.92 MB
Binary file not shown.
Binary file not shown.

labs/data/LA_Hub_Datasets/Trailheads.csv

Lines changed: 321 additions & 0 deletions
Large diffs are not rendered by default.

labs/data/LA_Hub_Datasets/Trails.geojson

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

labs/download_data.ipynb

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
" <a href='https://www.arcgis.com/home/item.html?id=a04933c045714492bda6886f355416f2' target='_blank'><b>LA_Hub_Datasets</b>\n",
6868
" </a>\n",
6969
" <br/>Datasets for ArcGIS DevLabs<img src='https://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\">Code Sample by esri_devlabs\n",
70-
" <br/>Last Modified: October 09, 2017\n",
71-
" <br/>0 comments, 5,936 views\n",
70+
" <br/>Last Modified: April 08, 2019\n",
71+
" <br/>0 comments, 6,226 views\n",
7272
" </div>\n",
7373
" </div>\n",
7474
" "
@@ -89,75 +89,54 @@
8989
},
9090
{
9191
"cell_type": "code",
92-
"execution_count": 10,
93-
"metadata": {},
94-
"outputs": [],
95-
"source": [
96-
"# configure where we should save our data, and where the ZIP file is located\n",
97-
"\n",
98-
"download_path = Path('./data')\n",
99-
"\n",
100-
"if not download_path.exists():\n",
101-
" download_path.mkdir()\n",
102-
"\n",
103-
"zip_path = download_path.joinpath('LA_Hub_Datasets.zip')\n",
104-
"extract_path = download_path.joinpath('LA_Hub_datasets')"
105-
]
106-
},
107-
{
108-
"cell_type": "code",
109-
"execution_count": 11,
92+
"execution_count": 6,
11093
"metadata": {},
11194
"outputs": [
11295
{
11396
"data": {
11497
"text/plain": [
115-
"'data/LA_Hub_Datasets.zip'"
98+
"'./data/LAHubDatasets.zip'"
11699
]
117100
},
118-
"execution_count": 11,
101+
"execution_count": 6,
119102
"metadata": {},
120103
"output_type": "execute_result"
121104
}
122105
],
123106
"source": [
124-
"# Download the LA Hub Dataset \n",
125-
"\n",
126-
"data_item.download(save_path=download_path)"
107+
"temp_path = os.path.join('.', 'data')\n",
108+
"data_item.download(save_path = temp_path)"
127109
]
128110
},
129111
{
130112
"cell_type": "code",
131-
"execution_count": 7,
113+
"execution_count": 16,
132114
"metadata": {},
133115
"outputs": [],
134116
"source": [
135-
"# Extract the data\n",
136-
"\n",
137-
"zip_file = ZipFile(zip_path)\n",
138-
"zip_file.extractall(path=extract_path)"
117+
"zf = ZipFile(os.path.join(temp_path, 'LAHubDatasets.zip'))\n",
118+
"zf.extractall(path = os.path.join(temp_path, ''))"
139119
]
140120
},
141121
{
142122
"cell_type": "code",
143-
"execution_count": 8,
123+
"execution_count": 18,
144124
"metadata": {},
145125
"outputs": [
146126
{
147127
"data": {
148128
"text/plain": [
149-
"['Parks_and_Open_Space.zip', 'Trails.geojson', '__MACOSX', 'Trailheads.csv']"
129+
"['Parks_and_Open_Space.zip', 'Trails.geojson', 'Trailheads.csv']"
150130
]
151131
},
152-
"execution_count": 8,
132+
"execution_count": 18,
153133
"metadata": {},
154134
"output_type": "execute_result"
155135
}
156136
],
157137
"source": [
158-
"# list the files in our data path\n",
159-
"\n",
160-
"list(file.name for file in extract_path.glob('*'))"
138+
"file_list = os.listdir(os.path.join(temp_path, 'LA_Hub_datasets'))\n",
139+
"file_list"
161140
]
162141
}
163142
],

labs/import_data.ipynb

Lines changed: 26 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -31,110 +31,81 @@
3131
},
3232
{
3333
"cell_type": "code",
34-
"execution_count": 35,
35-
"metadata": {},
36-
"outputs": [
37-
{
38-
"name": "stdout",
39-
"output_type": "stream",
40-
"text": [
41-
"Enter password, please: ········\n"
42-
]
43-
}
44-
],
45-
"source": [
46-
"from arcgis.gis import GIS\n",
47-
"import getpass\n",
48-
"\n",
49-
"password = getpass.getpass(\"Enter password, please: \")\n",
50-
"gis = GIS('https://arcgis.com', 'username', password)"
51-
]
52-
},
53-
{
54-
"cell_type": "code",
55-
"execution_count": 6,
34+
"execution_count": 17,
5635
"metadata": {},
5736
"outputs": [],
5837
"source": [
59-
"parks_properties = {\n",
60-
" 'title': 'Parks and Open Space',\n",
61-
" 'tags': 'parks, open data, tutorials',\n",
62-
" 'type': 'Shapefile'\n",
63-
"}"
38+
"from arcgis.gis import GIS\n",
39+
"import os"
6440
]
6541
},
6642
{
6743
"cell_type": "markdown",
6844
"metadata": {},
6945
"source": [
70-
"### Download Data"
46+
"To create the GIS object, we pass your profile that contains the url and your login credentials. Please replace the credentials below with that of your org. To learn more about profiles, see [here](https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/#Storing-your-credentialls-locally)."
7147
]
7248
},
7349
{
7450
"cell_type": "code",
75-
"execution_count": 37,
51+
"execution_count": 18,
7652
"metadata": {},
7753
"outputs": [],
7854
"source": [
79-
"# config from the Download Data Tutorial\n",
80-
"from pathlib import Path\n",
81-
"\n",
82-
"data_path = Path('./data')\n",
83-
"\n",
84-
"if not data_path.exists():\n",
85-
" data_path.mkdir()\n",
86-
"\n",
87-
"zip_path = data_path.joinpath('LA_Hub_Datasets.zip')\n",
88-
"extract_path = data_path.joinpath('LA_Hub_datasets')"
55+
"gis = GIS(profile='your_online_profile')"
8956
]
9057
},
9158
{
92-
"cell_type": "markdown",
59+
"cell_type": "code",
60+
"execution_count": 10,
9361
"metadata": {},
62+
"outputs": [],
9463
"source": [
95-
"### Import Data"
64+
"parks_properties = {'title': 'Parks and Open Space',\n",
65+
" 'tags': 'parks, open data, devlabs',\n",
66+
" 'type': 'Shapefile'}\n",
67+
"data_path = os.path.join('.', 'data', 'LA_Hub_datasets', 'Parks_and_Open_Space.zip')"
9668
]
9769
},
9870
{
9971
"cell_type": "code",
100-
"execution_count": 30,
72+
"execution_count": 19,
10173
"metadata": {},
10274
"outputs": [],
10375
"source": [
104-
"parks_shp_path = extract_path.joinpath('Parks_and_Open_Space.zip')\n",
105-
"parks_shp = gis.content.add(parks_properties, data=str(parks_shp_path))"
76+
"parks_shp = gis.content.add(parks_properties, data=data_path)"
10677
]
10778
},
10879
{
10980
"cell_type": "code",
110-
"execution_count": 31,
81+
"execution_count": 20,
11182
"metadata": {},
11283
"outputs": [
11384
{
11485
"data": {
11586
"text/html": [
11687
"<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
11788
" <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
118-
" <a href='https://cff-dev.maps.arcgis.com/home/item.html?id=e1667ca0ce4f4036af5c22708c595be7' target='_blank'>\n",
89+
" <a href='https://geosaurus.maps.arcgis.com/home/item.html?id=7e7d17040fdf4b35b2e5e5fef7eed7cf' target='_blank'>\n",
11990
" <img src='http://static.arcgis.com/images/desktopapp.png' class=\"itemThumbnail\">\n",
12091
" </a>\n",
12192
" </div>\n",
12293
"\n",
12394
" <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n",
124-
" <a href='https://cff-dev.maps.arcgis.com/home/item.html?id=e1667ca0ce4f4036af5c22708c595be7' target='_blank'><b>Parks and Open Space</b>\n",
95+
" <a href='https://geosaurus.maps.arcgis.com/home/item.html?id=7e7d17040fdf4b35b2e5e5fef7eed7cf' target='_blank'><b>Parks and Open Space</b>\n",
12596
" </a>\n",
126-
" <br/><img src='https://cff-dev.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/datafiles16.png' style=\"vertical-align:middle;\">Shapefile by cff_dev\n",
127-
" <br/>Last Modified: March 11, 2019\n",
97+
" <br/><img src='https://geosaurus.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/datafiles16.png' style=\"vertical-align:middle;\">Shapefile by arcgis_python\n",
98+
" <br/>Last Modified: April 11, 2019\n",
12899
" <br/>0 comments, 0 views\n",
129100
" </div>\n",
130101
" </div>\n",
131102
" "
132103
],
133104
"text/plain": [
134-
"<Item title:\"Parks and Open Space\" type:Shapefile owner:cff_dev>"
105+
"<Item title:\"Parks and Open Space\" type:Shapefile owner:arcgis_python>"
135106
]
136107
},
137-
"execution_count": 31,
108+
"execution_count": 20,
138109
"metadata": {},
139110
"output_type": "execute_result"
140111
}
@@ -145,7 +116,7 @@
145116
},
146117
{
147118
"cell_type": "code",
148-
"execution_count": 32,
119+
"execution_count": 21,
149120
"metadata": {},
150121
"outputs": [],
151122
"source": [
@@ -154,16 +125,16 @@
154125
},
155126
{
156127
"cell_type": "code",
157-
"execution_count": 33,
128+
"execution_count": 22,
158129
"metadata": {},
159130
"outputs": [
160131
{
161132
"data": {
162133
"text/plain": [
163-
"'https://services9.arcgis.com/ZPYuLYCJmpcXcod0/arcgis/rest/services/Parks_and_Open_Space/FeatureServer'"
134+
"'https://services7.arcgis.com/JEwYeAy2cc8qOe3o/arcgis/rest/services/Parks_and_Open_Space/FeatureServer'"
164135
]
165136
},
166-
"execution_count": 33,
137+
"execution_count": 22,
167138
"metadata": {},
168139
"output_type": "execute_result"
169140
}

0 commit comments

Comments
 (0)