|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 1, |
6 | | - "metadata": {}, |
7 | | - "outputs": [ |
8 | | - { |
9 | | - "name": "stdout", |
10 | | - "output_type": "stream", |
11 | | - "text": [ |
12 | | - "Please enter password: ········\n", |
13 | | - "Successfully logged in to browns.maps.arcgis.com as johnnyDev\n" |
14 | | - ] |
15 | | - } |
16 | | - ], |
| 5 | + "execution_count": null, |
| 6 | + "metadata": { |
| 7 | + "collapsed": false |
| 8 | + }, |
| 9 | + "outputs": [], |
17 | 10 | "source": [ |
18 | 11 | "import getpass\n", |
19 | 12 | "from arcgis.gis import GIS\n", |
|
27 | 20 | }, |
28 | 21 | { |
29 | 22 | "cell_type": "code", |
30 | | - "execution_count": 25, |
31 | | - "metadata": {}, |
32 | | - "outputs": [ |
33 | | - { |
34 | | - "data": { |
35 | | - "application/vnd.jupyter.widget-view+json": { |
36 | | - "model_id": "8682d282eada4f26b06fed0dd34563c5" |
37 | | - } |
38 | | - }, |
39 | | - "metadata": {}, |
40 | | - "output_type": "display_data" |
41 | | - }, |
42 | | - { |
43 | | - "name": "stdout", |
44 | | - "output_type": "stream", |
45 | | - "text": [ |
46 | | - "<class 'list'>\n" |
47 | | - ] |
48 | | - } |
49 | | - ], |
| 23 | + "execution_count": null, |
| 24 | + "metadata": { |
| 25 | + "collapsed": false |
| 26 | + }, |
| 27 | + "outputs": [], |
50 | 28 | "source": [ |
51 | 29 | "map1 = gis.map('Los Angeles', 10)\n", |
52 | 30 | "map1" |
53 | 31 | ] |
54 | 32 | }, |
55 | 33 | { |
56 | 34 | "cell_type": "code", |
57 | | - "execution_count": 8, |
58 | | - "metadata": {}, |
59 | | - "outputs": [ |
60 | | - { |
61 | | - "data": { |
62 | | - "text/plain": [ |
63 | | - "[<Item title:\"Griffith Park for Notebook\" type:Feature Layer Collection owner:johnnyDev>,\n", |
64 | | - " <Item title:\"Griffith Park CLTool\" type:Feature Layer Collection owner:johnnyDev>]" |
65 | | - ] |
66 | | - }, |
67 | | - "execution_count": 8, |
68 | | - "metadata": {}, |
69 | | - "output_type": "execute_result" |
70 | | - } |
71 | | - ], |
| 35 | + "execution_count": null, |
| 36 | + "metadata": { |
| 37 | + "collapsed": false |
| 38 | + }, |
| 39 | + "outputs": [], |
72 | 40 | "source": [ |
73 | 41 | "# retrieve feature layer to add attributes to\n", |
74 | 42 | "# search for feature layers\n", |
|
80 | 48 | }, |
81 | 49 | { |
82 | 50 | "cell_type": "code", |
83 | | - "execution_count": 9, |
84 | | - "metadata": {}, |
85 | | - "outputs": [ |
86 | | - { |
87 | | - "data": { |
88 | | - "text/plain": [ |
89 | | - "'griffith_park_for_notebook'" |
90 | | - ] |
91 | | - }, |
92 | | - "execution_count": 9, |
93 | | - "metadata": {}, |
94 | | - "output_type": "execute_result" |
95 | | - } |
96 | | - ], |
| 51 | + "execution_count": null, |
| 52 | + "metadata": { |
| 53 | + "collapsed": false |
| 54 | + }, |
| 55 | + "outputs": [], |
97 | 56 | "source": [ |
98 | 57 | "# retrieve the fl collection item, then the list of \n", |
99 | 58 | "# layers from the layers property, and the layer you want\n", |
|
105 | 64 | }, |
106 | 65 | { |
107 | 66 | "cell_type": "code", |
108 | | - "execution_count": 26, |
| 67 | + "execution_count": null, |
109 | 68 | "metadata": { |
110 | 69 | "collapsed": true |
111 | 70 | }, |
112 | 71 | "outputs": [], |
113 | 72 | "source": [ |
114 | | - "from arcgis import geocoding\n", |
| 73 | + "#from arcgis import geocoding\n", |
115 | 74 | "from arcgis import geometry\n", |
116 | 75 | "from arcgis import features\n", |
117 | 76 | "\n", |
118 | | - "def find_addr(map1, g):\n", |
| 77 | + "def create_feature(map1, g):\n", |
119 | 78 | " try:\n", |
| 79 | + " oid = 1\n", |
120 | 80 | " #geocoded = geocoding.reverse_geocode(g)\n", |
121 | 81 | " #print(geocoded['address']['Match_addr'])\n", |
122 | 82 | " pt = geometry.Point(g)\n", |
123 | | - " feat = features.Feature(geometry=pt)\n", |
124 | | - " flayer.edit[feat]\n", |
125 | | - " map1.draw(pt)\n", |
| 83 | + " feat = features.Feature(geometry=pt, attributes={'OBJECTID': oid})\n", |
| 84 | + " flayer.edit_features(adds=[feat])\n", |
| 85 | + " print(str(g))\n", |
| 86 | + " map1.draw(g)\n", |
| 87 | + " oid += 1\n", |
126 | 88 | " except:\n", |
127 | | - " print(\"Couldn't match address. Try another place...\")\n", |
128 | | - "\n", |
129 | | - "def pop_layer(map1, g):\n", |
130 | | - " feat_list = []\n", |
131 | | - " pt = geometry.Point(g)\n", |
132 | | - " feat_list.append(features.Feature(geometry=pt))\n", |
133 | | - " return feat_list" |
| 89 | + " print(\"Couldn't match address. Try another place...\")" |
134 | 90 | ] |
135 | 91 | }, |
136 | 92 | { |
137 | 93 | "cell_type": "code", |
138 | | - "execution_count": 27, |
| 94 | + "execution_count": null, |
139 | 95 | "metadata": { |
140 | 96 | "collapsed": true |
141 | 97 | }, |
142 | 98 | "outputs": [], |
143 | 99 | "source": [ |
144 | | - "map1.on_click(find_addr)" |
| 100 | + "map1.on_click(create_feature)" |
145 | 101 | ] |
146 | 102 | }, |
147 | 103 | { |
148 | 104 | "cell_type": "code", |
149 | | - "execution_count": 20, |
| 105 | + "execution_count": null, |
150 | 106 | "metadata": { |
151 | 107 | "collapsed": true |
152 | 108 | }, |
|
184 | 140 | "name": "python", |
185 | 141 | "nbconvert_exporter": "python", |
186 | 142 | "pygments_lexer": "ipython3", |
187 | | - "version": "3.5.3" |
| 143 | + "version": "3.5.2" |
188 | 144 | } |
189 | 145 | }, |
190 | 146 | "nbformat": 4, |
|
0 commit comments