Skip to content

Commit 498a834

Browse files
author
Yongyao Jiang
committed
Fix for create data
1 parent b2cbc61 commit 498a834

File tree

7 files changed

+445
-171
lines changed

7 files changed

+445
-171
lines changed

labs/create_data.ipynb

Lines changed: 50 additions & 101 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: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
},
1717
{
1818
"cell_type": "code",
19-
"execution_count": 8,
20-
"metadata": {
21-
"collapsed": true
22-
},
19+
"execution_count": 1,
20+
"metadata": {},
2321
"outputs": [],
2422
"source": [
2523
"from arcgis.gis import *\n",
@@ -30,9 +28,7 @@
3028
{
3129
"cell_type": "code",
3230
"execution_count": 2,
33-
"metadata": {
34-
"collapsed": true
35-
},
31+
"metadata": {},
3632
"outputs": [],
3733
"source": [
3834
"public_data_item_id = 'a04933c045714492bda6886f355416f2'"
@@ -41,9 +37,7 @@
4137
{
4238
"cell_type": "code",
4339
"execution_count": 3,
44-
"metadata": {
45-
"collapsed": true
46-
},
40+
"metadata": {},
4741
"outputs": [],
4842
"source": [
4943
"anon_gis = GIS()"
@@ -59,17 +53,17 @@
5953
"text/html": [
6054
"<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",
6155
" <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
62-
" <a href='http://www.arcgis.com/home/item.html?id=a04933c045714492bda6886f355416f2' target='_blank'>\n",
63-
" <img src='http://www.arcgis.com/sharing/rest//content/items/a04933c045714492bda6886f355416f2/info/thumbnail/thumbnail.png' class=\"itemThumbnail\">\n",
56+
" <a href='https://www.arcgis.com/home/item.html?id=a04933c045714492bda6886f355416f2' target='_blank'>\n",
57+
" <img src='https://www.arcgis.com/sharing/rest//content/items/a04933c045714492bda6886f355416f2/info/thumbnail/thumbnail.png' class=\"itemThumbnail\">\n",
6458
" </a>\n",
6559
" </div>\n",
6660
"\n",
6761
" <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n",
68-
" <a href='http://www.arcgis.com/home/item.html?id=a04933c045714492bda6886f355416f2' target='_blank'><b>LA_Hub_Datasets</b>\n",
62+
" <a href='https://www.arcgis.com/home/item.html?id=a04933c045714492bda6886f355416f2' target='_blank'><b>LA_Hub_Datasets</b>\n",
6963
" </a>\n",
70-
" <br/>Datasets for ArcGIS DevLabs<img src='http://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\">Code Sample by esri_devlabs\n",
71-
" <br/>Last Modified: October 09, 2017\n",
72-
" <br/>0 comments, 1,605 views\n",
64+
" <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",
65+
" <br/>Last Modified: April 08, 2019\n",
66+
" <br/>0 comments, 6,226 views\n",
7367
" </div>\n",
7468
" </div>\n",
7569
" "
@@ -90,62 +84,61 @@
9084
},
9185
{
9286
"cell_type": "code",
93-
"execution_count": 5,
87+
"execution_count": 6,
9488
"metadata": {},
9589
"outputs": [
9690
{
9791
"data": {
9892
"text/plain": [
99-
"'./LA_Hub_Datasets.zip'"
93+
"'./data/LAHubDatasets.zip'"
10094
]
10195
},
102-
"execution_count": 5,
96+
"execution_count": 6,
10397
"metadata": {},
10498
"output_type": "execute_result"
10599
}
106100
],
107101
"source": [
108-
"data_item.download(save_path = r'./')"
102+
"temp_path = os.path.join('.', 'data')\n",
103+
"data_item.download(save_path = temp_path)"
109104
]
110105
},
111106
{
112107
"cell_type": "code",
113-
"execution_count": 6,
114-
"metadata": {
115-
"collapsed": true
116-
},
108+
"execution_count": 16,
109+
"metadata": {},
117110
"outputs": [],
118111
"source": [
119-
"zf = ZipFile(r'./LA_Hub_Datasets.zip')\n",
120-
"zf.extractall(path=r'./LA_Hub_datasets')"
112+
"zf = ZipFile(os.path.join(temp_path, 'LAHubDatasets.zip'))\n",
113+
"zf.extractall(path = os.path.join(temp_path, ''))"
121114
]
122115
},
123116
{
124117
"cell_type": "code",
125-
"execution_count": 7,
118+
"execution_count": 18,
126119
"metadata": {},
127120
"outputs": [
128121
{
129122
"data": {
130123
"text/plain": [
131-
"['Parks_and_Open_Space.zip', 'Trails.geojson', '__MACOSX', 'Trailheads.csv']"
124+
"['Parks_and_Open_Space.zip', 'Trails.geojson', 'Trailheads.csv']"
132125
]
133126
},
134-
"execution_count": 7,
127+
"execution_count": 18,
135128
"metadata": {},
136129
"output_type": "execute_result"
137130
}
138131
],
139132
"source": [
140-
"file_list = os.listdir(r'./LA_Hub_datasets/')\n",
133+
"file_list = os.listdir(os.path.join(temp_path, 'LA_Hub_datasets'))\n",
141134
"file_list"
142135
]
143136
}
144137
],
145138
"metadata": {
146139
"anaconda-cloud": {},
147140
"kernelspec": {
148-
"display_name": "Python [default]",
141+
"display_name": "Python 3",
149142
"language": "python",
150143
"name": "python3"
151144
},
@@ -159,7 +152,7 @@
159152
"name": "python",
160153
"nbconvert_exporter": "python",
161154
"pygments_lexer": "ipython3",
162-
"version": "3.5.3"
155+
"version": "3.7.2"
163156
}
164157
},
165158
"nbformat": 4,

labs/import_data.ipynb

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,69 +29,81 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": 16,
32+
"execution_count": 17,
3333
"metadata": {},
34-
"outputs": [
35-
{
36-
"name": "stdout",
37-
"output_type": "stream",
38-
"text": [
39-
"Enter password, please: ········\n"
40-
]
41-
}
42-
],
34+
"outputs": [],
4335
"source": [
44-
"import getpass\n",
45-
"\n",
46-
"password = getpass.getpass(\"Enter password, please: \")\n",
47-
"gis = GIS('https://arcgis.com', 'username', password)"
36+
"from arcgis.gis import GIS\n",
37+
"import os"
38+
]
39+
},
40+
{
41+
"cell_type": "markdown",
42+
"metadata": {},
43+
"source": [
44+
"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)."
4845
]
4946
},
5047
{
5148
"cell_type": "code",
52-
"execution_count": 17,
53-
"metadata": {
54-
"collapsed": true
55-
},
49+
"execution_count": 18,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"gis = GIS(profile='your_online_profile')"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": 10,
59+
"metadata": {},
5660
"outputs": [],
5761
"source": [
5862
"parks_properties = {'title': 'Parks and Open Space',\n",
59-
" 'tags': 'parks, open data, devlabs',\n",
60-
" 'type': 'Shapefile'}\n",
61-
"parks_shp = gis.content.add(parks_properties,\n",
62-
" data='./LA_Hub_datasets/Parks_and_Open_Space.zip')"
63+
" 'tags': 'parks, open data, devlabs',\n",
64+
" 'type': 'Shapefile'}\n",
65+
"data_path = os.path.join('.', 'data', 'LA_Hub_datasets', 'Parks_and_Open_Space.zip')"
6366
]
6467
},
6568
{
6669
"cell_type": "code",
67-
"execution_count": 18,
70+
"execution_count": 19,
71+
"metadata": {},
72+
"outputs": [],
73+
"source": [
74+
"parks_shp = gis.content.add(parks_properties, data=data_path)"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": 20,
6880
"metadata": {},
6981
"outputs": [
7082
{
7183
"data": {
7284
"text/html": [
7385
"<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",
7486
" <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
75-
" <a href='https://arcgis.com/home/item.html?id=7d848422761f4d78bf986f9a1bc7ad1b' target='_blank'>\n",
87+
" <a href='https://geosaurus.maps.arcgis.com/home/item.html?id=7e7d17040fdf4b35b2e5e5fef7eed7cf' target='_blank'>\n",
7688
" <img src='http://static.arcgis.com/images/desktopapp.png' class=\"itemThumbnail\">\n",
7789
" </a>\n",
7890
" </div>\n",
7991
"\n",
8092
" <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n",
81-
" <a href='https://arcgis.com/home/item.html?id=7d848422761f4d78bf986f9a1bc7ad1b' target='_blank'><b>Parks and Open Space</b>\n",
93+
" <a href='https://geosaurus.maps.arcgis.com/home/item.html?id=7e7d17040fdf4b35b2e5e5fef7eed7cf' target='_blank'><b>Parks and Open Space</b>\n",
8294
" </a>\n",
83-
" <br/><img src='https://arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/datafiles16.png' style=\"vertical-align:middle;\">Shapefile by johnnyDev\n",
84-
" <br/>Last Modified: September 28, 2017\n",
95+
" <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",
96+
" <br/>Last Modified: April 11, 2019\n",
8597
" <br/>0 comments, 0 views\n",
8698
" </div>\n",
8799
" </div>\n",
88100
" "
89101
],
90102
"text/plain": [
91-
"<Item title:\"Parks and Open Space\" type:Shapefile owner:johnnyDev>"
103+
"<Item title:\"Parks and Open Space\" type:Shapefile owner:arcgis_python>"
92104
]
93105
},
94-
"execution_count": 18,
106+
"execution_count": 20,
95107
"metadata": {},
96108
"output_type": "execute_result"
97109
}
@@ -102,27 +114,25 @@
102114
},
103115
{
104116
"cell_type": "code",
105-
"execution_count": 19,
106-
"metadata": {
107-
"collapsed": true
108-
},
117+
"execution_count": 21,
118+
"metadata": {},
109119
"outputs": [],
110120
"source": [
111121
"parks_feature_layer = parks_shp.publish()"
112122
]
113123
},
114124
{
115125
"cell_type": "code",
116-
"execution_count": 20,
126+
"execution_count": 22,
117127
"metadata": {},
118128
"outputs": [
119129
{
120130
"data": {
121131
"text/plain": [
122-
"'https://services1.arcgis.com/uRIm5IkWjDXybgFb/arcgis/rest/services/Parks_and_Open_Space/FeatureServer'"
132+
"'https://services7.arcgis.com/JEwYeAy2cc8qOe3o/arcgis/rest/services/Parks_and_Open_Space/FeatureServer'"
123133
]
124134
},
125-
"execution_count": 20,
135+
"execution_count": 22,
126136
"metadata": {},
127137
"output_type": "execute_result"
128138
}
@@ -135,7 +145,7 @@
135145
"metadata": {
136146
"anaconda-cloud": {},
137147
"kernelspec": {
138-
"display_name": "Python [default]",
148+
"display_name": "Python 3",
139149
"language": "python",
140150
"name": "python3"
141151
},
@@ -149,7 +159,7 @@
149159
"name": "python",
150160
"nbconvert_exporter": "python",
151161
"pygments_lexer": "ipython3",
152-
"version": "3.5.3"
162+
"version": "3.7.2"
153163
}
154164
},
155165
"nbformat": 4,

0 commit comments

Comments
 (0)