Edit features

A feature has a geometry, multiple attributes, and, potentially, attachments. For details about editing and creating geometry, see Edit geometry. If you want to allow users to edit existing attributes and attachments, the recommendation is to use feature forms; see Edit using feature forms. If you are calculating values for attributes and attachments without user input, see the following sections about creating, deleting, and updating a feature using the FeatureTable API.

Create, delete, update features with FeatureTable

You can create or delete features, or update existing features, using the FeatureTable API.

The API gives you more fine-grained control over feature editing operations, including create and edit features, add, edit, or remove feature attachments, and edit feature geometry.

For editing workflows that use a local geodatabase, you can use geodatabase transactions to group and manage a set of edits as a single item (transaction). This makes it easier to control when those edits are committed (saved) or rolled back (discarded) as a single unit.

The enterprise geodatabase can use versioning to support multiuser editing scenarios and long transactions. If you require multiple editors to concurrently access services with the ability to undo and redo their edits, you can implement branch versions in your ArcGIS Enterprise portal. For more information, see Branch versioned data in this guide or Share branch versioned data in the ArcGIS Pro documentation.

For some feature service editing workflows, it's recommended that an analyst using ArcGIS Pro periodically review edits and verify data integrity. Although the API can perform some types of data validation, other validation tasks, such as validating topologies, cannot be performed using the API alone.

If necessary, feature editing can be separated into two parts: geometry editing and attribute editing. In certain scenarios, you may only be interested in editing the location of a feature, while at other times you might only want to edit attributes and attachments. The referenced documentation explores editing the individual parts of the feature in greater detail.

Add features

Apps often allow users to create a new feature by clicking on the map to indicate the feature's location. You can provide this capability by listening for a click event on your map view and adding a new feature in the event handler.

To add features to a feature table, create a new feature from geometry (for example, point, line, or polygon), create attributes for the new feature, and then call add feature. This adds the feature to a table stored locally on your device.

If these local edits need to be shared with the parent feature service, call ServiceGeodatabase.applyEdits() on the table's ServiceGeodatabase. See Apply edits from the service geodatabase for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
        lifecycleScope.launch {

            // Create attributes for the feature.
            val attributes = mutableMapOf(
                "firstname" to "John",
                "lastname" to "Doe",
                "typdamage" to "Minor",
                "primcause" to "Earthquake"
            )

            // Create a new feature from the attributes and the point.
            val arcGISFeature = damagePointsTable.createFeature(attributes, point) as? ArcGISFeature
                ?: return@launch logErr("New feature is not an ArcGISFeature.")

            // Check if features can be added to the feature table.
            if (damagePointsTable.canAdd()) {
                // Add the feature to the local table.
                damagePointsTable.addFeature(arcGISFeature).onFailure { error ->
                    return@launch logErr("Could not add feature to table: ${error.message}")
                    // If the feature table is a service feature table, then
                    // apply edits to its service geodatabase.
                    // ...
                }
            }

        }

Add true curves

Your app can add features with true curves to ArcGIS feature services that support true curves.

You can use ArcGISFeatureServiceInfo to find out what type of curve support a feature service has and adapt your app's behavior accordingly. For example, if the service doesn't support true curves, you can densify any curve geometries before sending them to the service. Or, if the service does support true curves, you could use the serviceCurveGeometryMode to fetch curve geometries, and reactively enable a curve-aware user experience in your app. ArcGIS REST API feature service reference contains more details about curve support.

For geometry information about true curves, see the Segments section in the Geometry topic.

Delete features

You can delete several features from a feature table using the delete features method that accepts a list of features, or just a single feature with a call to delete feature. All edits are stored in the feature table on the client.

If these edits need to be shared with the parent feature service, apply them to the table's service geodatabase. See Apply edits from the service geodatabase for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
                val selectedFeatures = damageLayer.getSelectedFeatures().getOrElse { error ->
                    return@launch logErr("Could not get list of selected features: ${error.message}")
                }

                // Delete the features.
                damagePointsTable.deleteFeatures(selectedFeatures)

                // If the feature table is a service feature table, then apply edits to
                // its service geodatabase.
                // serviceGdb.applyEdits()

Update features

Feature updates include moving or reshaping a feature's geometry or making edits to attribute values. All edits are stored in the feature table on the client.

If these edits need to be shared with the parent feature service, apply them to the table's service geodatabase. See Apply edits from the service geodatabase for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
            // Check if the feature can be updated.
            if (damagePointsTable.canUpdate(arcGISFeature)) {
                // Change the feature's attribute value.
                arcGISFeature.attributes["typdamage"] = "Inaccessible"

                // Check if the feature's geometry can be edited.
                if (arcGISFeature.canUpdateGeometry) {
                    // Change the feature's geometry.
                    val currentLocation = arcGISFeature.geometry as? Point
                        ?: return@launch logErr("Current feature does not have a point geometry.")
                    val newLocation =
                        Point(
                            x = currentLocation.x,
                            y = currentLocation.y + 250.0,
                            spatialReference = map.spatialReference
                        )
                    arcGISFeature.geometry = newLocation
                }

                // Update the feature on the local table.
                damagePointsTable.updateFeature(arcGISFeature).onFailure { error ->
                    return@launch logErr("Could not update feature in table: ${error.message}")
                }
                // If the feature table is a service feature table, then
                // apply edits to its service geodatabase.
                // ...
            }

Update true curves

Feature services can be published with protections that disallow edits to existing true curves from curve-unaware clients. Use properties on ArcGISFeatureServiceInfo to find out what curve support a feature service has. ArcGIS REST API feature service reference contains more details about curve support.

Edit attachments

If the feature's table has attachments enabled, you can associate documents and photographs with individual features. You can add any file, that has a supported attachment format, to the feature's collection of attachments using ArcGISFeature.addAttachment(). For more information about enabling attachments on the feature layer, see the ArcGIS Online, ArcGIS Enterprise, and ArcGIS Pro documentation.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                    if (serviceFeatureTable.hasAttachments) {
                        // Add the attachment to the selected feature.
                        arcGISFeature.addAttachment(
                            name = attachmentName,
                            contentType = "image/png",
                            data = imageBytes
                        ).onFailure {
                            return@launch showError(it.message.toString())
                        }
                        // Update the feature changes in the loaded service feature table.
                        serviceFeatureTable.updateFeature(arcGISFeature).getOrElse {
                            return@launch showError(it.message.toString())
                        }
                    }

If the feature's table has attachments enabled and the feature's attachment collection can be edited, you can update any attachment with new details.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                if (serviceFeatureTable.hasAttachments && arcGISFeature.canEditAttachments) {
                    // Delete the attachment from the selected feature.
                    arcGISFeature.updateAttachment(
                        attachmentInfo = attachment,
                        name = "DamagedTree.png",
                        contentType = "png",
                        data = dataElement
                    ).getOrElse {
                        return@launch showError(it.message.toString())
                    }
                    // Update the feature changes in the loaded service feature table.
                    serviceFeatureTable.updateFeature(arcGISFeature).getOrElse {
                        return@launch showError(it.message.toString())
                    }
                }

Or, you can remove any attachment from the feature's attachment collection.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
                    // Delete the attachment from the selected feature.
                    arcGISFeature.deleteAttachment(attachment).getOrElse {
                        return@launch showError(it.message.toString())
                    }
                    // Update the feature changes in the loaded service feature table.
                    serviceFeatureTable.updateFeature(arcGISFeature).getOrElse {
                        return@launch showError(it.message.toString())
                    }

Undo changes

There are times when making changes to data that you might want to undo all the edits in all of the local tables you are working with. The ServiceGeodatabase, a container for a collection of ServiceFeatureTables connected to a feature service, provides ServiceGeodatabase.hasLocalEdits() to determine if any of the tables have unapplied edits. If you confirm that edits exist, then you can use ServiceGeodatabase.undoLocalEdits() to asynchronously undo all of the local edits in all the tables. This logic could be applied before or after you apply or synchronize edits back to the feature service. In addition, you could utilize this logic during an editing workflow where you wish to provide a UI component to allow a user to undo their changes.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
            // Double-check edits exist in any of the local tables.
            if (serviceGdb.hasLocalEdits()) {
                lifecycleScope.launch {
                    // Undo all the local edits for all the tables in the service geodatabase.
                    serviceGeodatabase.undoLocalEdits().onFailure { error ->
                        return@launch logErr("Unable to undo local edits: ${error.message}")
                    }
                }
            }

Work with geometry

There are many ways you can create or edit geometries while editing features. If you have your geometry coordinates prepared before you begin, you can use geometry constructors to create the geometry all at once. When a more iterative process is required, you may need geometry builders to build or edit your geometry. Some actions that you perform on existing geometries can result in new geometries. In this case, the geometry engine provides geometric operations to help with that workflow. Lastly, if your application users want to create or edit geometries interactively in a map view, you can use the geometry editor. To learn more about these options and to help you determine which one fits your requirements, see the Edit geometry topic.

Work with attributes and attachments

The code examples illustrated above show a typical workflow for editing attribute values and attachments when adding, deleting, and updating features. In these scenarios, the manner in which the attribute values are obtained and validated are left to your creativity during application development.

Layers that implement FeatureFormSource support a ** feature form** that is designed to ease attribute and attachment editing and validation for a feature. This form guides the users to the correct fields, constrains allowed values for a field, and supports the addition of new attachments or replacement of existing ones. We recommend that you display this feature form in your app by utilizing the composable FeatureForm toolkit component. For more information, see the Edit using toolkit topic in this guide.

Edit data from a branch version

Edits can be made to service feature tables from a branch version the same way they are made to any ServiceFeatureTable. You can also follow the process described above for adding, deleting, and updating features or their attachments.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.