Perform edits

Fine grained control over editing operations is available by using the editing API, allowing you to create and edit features, add, edit or remove feature attachments, and edit the geometry of features.

For editing workflows that use a local geodatabase, you can use geodatabase transactions to manage a set of edits (transaction). You can then control when those edits are committed (saved) or rolled back (discarded) as a single unit.

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

For some feature service editing workflows, it's a good idea to have an analyst using ArcGIS Pro periodically review the edits to verify data integrity. Although components in the API can perform some data validation, other tasks such as validating topologies cannot be performed using the API alone.

Feature editing can be broken up into two parts, geometry or attribute editing, when the need arises. In certain scenarios, you might only be interested in editing the location of a feature, while in other situations you might only want to edit attributes and attachments. The referenced documentation will explore editing individual parts of the feature in greater detail.

Add features

For creating new features, it's common for an app to allow the user to click the map to specify a new feature's location. You can provide this capability by listening to a click event on your map view, which in turn will call a function for adding a new feature.

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 edits need to be shared with the parent feature service, apply them to the table's service geodatabase. See Apply edits to 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
// Create attributes for the feature.
Map<String, Object> attributes = new HashMap<>();
attributes.put("typdamage", "Minor");
attributes.put("primcause", "Earthquake");

// Create a new feature from the attributes and the point.
Feature feature = damageTable.createFeature(attributes, point);

// Check if features can be added to the feature table.
if (damageTable.canAdd()) {
    // Add the feature to the local table.
    ListenableFuture<Void> addFeatureFuture = damageTable.addFeatureAsync(feature);

    addFeatureFuture.addDoneListener(() -> {
        // 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 so that you can adapt your app behavior to it. 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 setServiceCurveGeometryMode() and ServiceCurveGeometryMode enum 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 on true curves, see Segments in the Geometry topic.

You may know true curves as parametric curves.

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 to 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
// Check if the feature can be updated.
if (damageTable.canUpdate(feature)) {
    // Change the feature's attribute value.
    feature.getAttributes().put("typdamage", "Inaccessible");

    // Check if the feature's geometry can be edited.
    if (feature.canUpdateGeometry()) {
        // Change the feature's geometry.
        Geometry featureGeometry = feature.getGeometry();

        if (featureGeometry instanceof Point location) {
            Point newLocation =
                new Point(location.getX(), location.getY() + 5000.0, map.getSpatialReference());

            feature.setGeometry(newLocation);
        }
    }

    // Update the feature on the local table.
    ListenableFuture<Void> updateFeatureFuture = damageTable.updateFeatureAsync(feature);
    updateFeatureFuture.addDoneListener(() -> {
        // 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. If your app supports preserving curve segments when editing, you can use the new setServiceCurveGeometryMode() and ServiceCurveGeometryMode enum to inform the service your app is a true-curve client. 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.

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 to 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
if (damageTable.getLayerInfo().getCapabilities().isSupportsDelete()) {
    try {
        // Get all selected features in the layer.
        ListenableFuture<FeatureQueryResult> selectedFeaturesFuture = damageLayer.getSelectedFeaturesAsync();

        selectedFeaturesFuture.addDoneListener(() -> {
            try {
                FeatureQueryResult featureQueryResult = selectedFeaturesFuture.get();

                // You can iterate through the features in the query result (FeatureQueryResult is an Iterable<Feature>)
                // to verify/examine them, and then delete the features.

                // ...

                // Delete all the selected features.
                ListenableFuture<Void> deleteFeatureFuture = damageTable.deleteFeaturesAsync(featureQueryResult);

                deleteFeatureFuture.addDoneListener(() -> {
                // If the feature table is a service feature table, then apply edits to
                // its service geodatabase.

                // ...
                });
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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.addAttachmentAsync(). For more information about enabling attachments on the feature layer, see the ArcGIS Online, ArcGIS Enterprise, and ArcGIS Pro documentation.

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.

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

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.undoLocalEditsAsync() 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
// Double-check edits exist in any of the local tables.
if (serviceGdb.hasLocalEdits()) {
    // Undo all edits in all local tables.
    serviceGdb.undoLocalEditsAsync();
}

Work with geometry

There are many ways you can go about creating or editing geometries when editing features. Knowing all your geometry coordinates up front, then geometry constructors can be used to create the geometry all at once. When a more iterative process is required to build up or edit your geometry, then geometry builders are better suited. You might also want to perform actions on existing geometries that result in new geometries. In this case, the geometry engine provides geometric operations to help with that workflow. Lastly, you want to create or edit geometries interactively in a map view to better support your application users. The geometry editor is well suited to help out in this use-case. To learn more about these options and help you determine which one fits your requirements best, see the Create and edit geometries topic.

Edit data from a branch version

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

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