Skip to content

Commit ff9914b

Browse files
committed
updated create lab to incorporate attributes dictionary and removed download data from import.
1 parent c5c80e8 commit ff9914b

File tree

2 files changed

+29
-121
lines changed

2 files changed

+29
-121
lines changed

labs/create_data.ipynb

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6-
"metadata": {
7-
"collapsed": true
8-
},
6+
"metadata": {},
97
"outputs": [],
108
"source": [
119
"import getpass\n",
@@ -20,61 +18,63 @@
2018
{
2119
"cell_type": "code",
2220
"execution_count": null,
23-
"metadata": {
24-
"collapsed": true
25-
},
21+
"metadata": {},
2622
"outputs": [],
2723
"source": [
28-
"flyr_search_results = dev_gis.content.search(query=\"\"\"title: \"Griffith*\" AND \n",
29-
" type: \"Feature Service\" \"\"\", \n",
24+
"feature_layer_srch_results = dev_gis.content.search(query='title: \"Griffith*\" AND type: \"Feature Service\"', \n",
3025
" max_items=10)\n",
31-
"flyr_search_results"
26+
"feature_layer_srch_results"
3227
]
3328
},
3429
{
3530
"cell_type": "code",
3631
"execution_count": null,
37-
"metadata": {
38-
"collapsed": true
39-
},
32+
"metadata": {},
4033
"outputs": [],
4134
"source": [
42-
"flyr_collection_item = flyr_search_results[0]\n",
43-
"flayers = flyr_collection_item.layers\n",
44-
"flayer = flayers[0]\n",
45-
"flayer.properties.name"
35+
"feature_layer_coll_item = feature_layer_srch_results[0]\n",
36+
"feature_layers = feature_layer_coll_item.layers\n",
37+
"feature_layer = feature_layers[0]\n",
38+
"feature_layer.properties.name"
4639
]
4740
},
4841
{
4942
"cell_type": "code",
5043
"execution_count": null,
51-
"metadata": {
52-
"collapsed": true
53-
},
44+
"metadata": {},
45+
"outputs": [],
46+
"source": [
47+
"for field in feature_layer.properties['fields']:\n",
48+
" print(field['name'])"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"metadata": {},
5455
"outputs": [],
5556
"source": [
5657
"from arcgis import geometry\n",
5758
"from arcgis import features\n",
5859
"\n",
5960
"def create_feature(map1, g):\n",
6061
" try:\n",
61-
" oid = 1\n",
6262
" pt = geometry.Point(g)\n",
63-
" feat = features.Feature(geometry=pt, attributes={'OBJECTID': oid})\n",
64-
" flayer.edit_features(adds=[feat])\n",
63+
" feat = features.Feature(geometry=pt, attributes={'OBJECTID': 1,\n",
64+
" 'name': 'name',\n",
65+
" 'type': 'park',\n",
66+
" 'surface': 'dirt'})\n",
67+
" feature_layer.edit_features(adds=[feat])\n",
6568
" print(str(g))\n",
6669
" map1.draw(g)\n",
67-
" oid += 1\n",
6870
" except:\n",
6971
" print(\"Couldn't create the feature. Try again, please...\")"
7072
]
7173
},
7274
{
7375
"cell_type": "code",
7476
"execution_count": null,
75-
"metadata": {
76-
"collapsed": true
77-
},
77+
"metadata": {},
7878
"outputs": [],
7979
"source": [
8080
"map1 = dev_gis.map('Los Angeles', 10)\n",
@@ -106,12 +106,10 @@
106106
{
107107
"cell_type": "code",
108108
"execution_count": null,
109-
"metadata": {
110-
"collapsed": true
111-
},
109+
"metadata": {},
112110
"outputs": [],
113111
"source": [
114-
"map1.add_layer(flayer)"
112+
"map1.add_layer(feature_layer)"
115113
]
116114
}
117115
],

labs/import_data.ipynb

Lines changed: 1 addition & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -11,96 +11,6 @@
1111
"If you have completed the [Download data lab](https://developers.arcgis.com/labs/python/download-data) and are still in that notebooks.esri.com session, skip to [The Import Data Lab](#import_section) section of this lab."
1212
]
1313
},
14-
{
15-
"cell_type": "markdown",
16-
"metadata": {},
17-
"source": [
18-
"#### The Download Data Lab\n",
19-
"<a id='download_section'></a>"
20-
]
21-
},
22-
{
23-
"cell_type": "code",
24-
"execution_count": null,
25-
"metadata": {
26-
"collapsed": true
27-
},
28-
"outputs": [],
29-
"source": [
30-
"from arcgis.gis import *\n",
31-
"import os\n",
32-
"from zipfile import ZipFile"
33-
]
34-
},
35-
{
36-
"cell_type": "code",
37-
"execution_count": null,
38-
"metadata": {
39-
"collapsed": true
40-
},
41-
"outputs": [],
42-
"source": [
43-
"public_data_item_id = 'a04933c045714492bda6886f355416f2'"
44-
]
45-
},
46-
{
47-
"cell_type": "code",
48-
"execution_count": null,
49-
"metadata": {
50-
"collapsed": true
51-
},
52-
"outputs": [],
53-
"source": [
54-
"anon_gis = GIS()"
55-
]
56-
},
57-
{
58-
"cell_type": "code",
59-
"execution_count": null,
60-
"metadata": {
61-
"collapsed": true
62-
},
63-
"outputs": [],
64-
"source": [
65-
"data_item = anon_gis.content.get(public_data_item_id)\n",
66-
"data_item"
67-
]
68-
},
69-
{
70-
"cell_type": "code",
71-
"execution_count": null,
72-
"metadata": {
73-
"collapsed": true
74-
},
75-
"outputs": [],
76-
"source": [
77-
"data_item.download(save_path = r'./')"
78-
]
79-
},
80-
{
81-
"cell_type": "code",
82-
"execution_count": null,
83-
"metadata": {
84-
"collapsed": true
85-
},
86-
"outputs": [],
87-
"source": [
88-
"zf = ZipFile(r'./LA_Hub_Datasets.zip')\n",
89-
"zf.extractall(path=r'./LA_Hub_datasets')"
90-
]
91-
},
92-
{
93-
"cell_type": "code",
94-
"execution_count": null,
95-
"metadata": {
96-
"collapsed": true
97-
},
98-
"outputs": [],
99-
"source": [
100-
"file_list = os.listdir(r'./LA_Hub_datasets/')\n",
101-
"file_list"
102-
]
103-
},
10414
{
10515
"cell_type": "markdown",
10616
"metadata": {},
@@ -120,7 +30,7 @@
12030
"import getpass\n",
12131
"\n",
12232
"password = getpass.getpass(\"Enter password, please: \")\n",
123-
"dev_gis = GIS('https://arcgis.com', 'johnnyDev', password)"
33+
"dev_gis = GIS('https://arcgis.com', 'username', password)"
12434
]
12535
},
12636
{

0 commit comments

Comments
 (0)