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
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 applyEdits() on the table's ServiceGeodatabase. See Apply edits from the service geodatabase for more information.
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.
// ...
}
}
}
For information on handling true curves when adding features, see Add true curves. To create features using predefined templates, see Use shared templates to create features.
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.
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.
// 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.
// ...
}
For information on handling true curves when updating features, see Update true curves.
Edit attachments
If the feature's table has attachments.png file) or a document, that is associated with individual features in a geodatabase or feature layer.ArcGISFeature.addAttachment(). You can attach the file directly or provide a path to the file which optimizes memory. Alongside adding attachments, you can associate a keyword. You may add a keyword upon adding an attachment or even update an existing attachment to add a keyword. Keywords can be used to identify or provide context for attachments. For more information about enabling attachments on the feature layer, see the ArcGIS Online, ArcGIS Enterprise, and ArcGIS Pro documentation.
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.png file) or a document, that is associated with individual features in a geodatabase or feature layer.
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.
// 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.
// 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.
Edit true curves
Geometries that appear on a map as curves can be represented in two ways: as true curves or as densified curves. True curves are mathematically defined curves, such as circular or elliptical arcs. Densified curves are made up of many short, straight line segments that approximate the shape of a curve. You can use ArcGISFeatureServiceInfo to find out what type of curve support a feature service provides and adapt your app's behavior accordingly. For example, if the service supports true curves, you can enable a curve-aware user experience in your app. Or, if the service doesn't support true curves, you can densify any curve geometries before sending them to the service. By default, your app's environment has ArcGISEnvironment.serviceCurveGeometryMode set to ServiceCurveGeometryMode.TrueCurveClient.
It is important to bear in mind that some GeometryEngine functionality will produce results by densifying curves. See GeometryEngine in the API Reference documentation for details.
For more information, see True curves in the Geometry topic.
Add true curves
Your app can add features with true curves to ArcGIS feature services that support true curves. Use properties on ArcGISFeatureServiceInfo to find out what curve support a feature service provides.
If your app's environment has ArcGISEnvironment.serviceCurveGeometryMode set to ServiceCurveGeometryMode.TrueCurveClient (the default value), your app will identify itself to the feature service as a true curve client when requesting existing geometries and when adding new features with true curve geometries.
Feature Service in the ArcGIS REST API
Update true curves
Feature services can be published with protections that disallow edits to existing true curves from curve-unaware clients. When a service is published with ArcGISFeatureServiceInfo.onlyAllowTrueCurveUpdatesByTrueCurveClients set to true, the author intends that feature geometries containing curves should only be changed by those clients that guarantee they correctly handle true curves.
If ArcGISEnvironment.serviceCurveGeometryMode is set to the default value ServiceCurveGeometryMode.TrueCurveClient, your app is identifying itself to a feature service as a true curve client, which has the following effects.
-
In online feature service editing workflows, not only will your app receive true curves when fetching existing geometries from the service, but it will also be allowed to submit updates to existing true curve geometries.
-
In offline feature service editing workflows, a sync-enabled mobile
Geodatabasewill contain true curve geometries ifArcGISEnvironment.serviceCurveGeometryModeis set toServiceCurveGeometryMode.TrueCurveClientat the time the geodatabase is created and downloaded. Thereafter, that geodatabase will always behave as a true curve client when edits are synchronized, as indicated byGeodatabase.isTrueCurveClientreturning true. -
In offline feature service editing workflows, web maps can be configured to maintain and download true curves. An on-demand offline map will honor this setting. Otherwise, the behavior is as above for sync-enabled mobile geodatabases.
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.
Use shared templates to create features
Shared templates simplify feature creation by reducing repetitive edits, improving consistency, and reinforcing data integrity. A SharedTemplate can define default attributes, symbology, tools, and geometry-construction behavior ensuring related content is created consistently. ServiceGeodatabase and Geodatabase support shared templates from ArcGIS Enterprise 11.3+ and ArcGIS Online feature services, as well as from standalone mobile geodatabases exported from ArcGIS Pro 3.6+.
Supported template types include:
- Feature: Creates a single feature with predefined attributes and behavior. For example, place an electric pole already configured as a 40-foot wood pole, or add a building feature with the correct use, height, and materials.
- Preset: Places a complete predefined assembly in one step. Utilities can add transformer banks or switch cabinets, while local governments can place standard site layouts, such as park amenities or traffic control setups, with related features created together.
- Group: Creates multiple related features from one sketch by applying Feature builder transformations (for example, offsets, buffers, and intervals) to a base geometry. This supports workflows such as drawing a service line and automatically adding connected assets, or placing rows of street trees, parking spaces, signs, or streetlights.
Together, these templates help developers deliver guided, high-productivity editing experiences across utility and non-utility datasets, with built-in domain logic and minimal user input.
Typical workflow:
- Query templates with
querySharedTemplates(). UseSharedTemplateQueryParametersto filter by layer, tag, visibility, or source. - Build an in-memory feature set with
createFeatures(). This returns aSharedTemplateFeatureCreationSetcontaining features generated by the template, with attributes that can be reviewed and modified before committing. - Commit this feature set with
addFeatures(). TheSharedTemplateFeatureCreationSetis committed transactionally (all-or-nothing).
For utility network datasets, preset and group templates can also optionally create utility associations for generated features.
Many apps already use layer-level FeatureTemplate objects to power template pickers and create single features. To support a unified picker workflow, include these templates in shared template queries by setting SharedTemplateQueryParameters.sourceType to Layer or All. Returned FeatureTemplate values are automatically upgraded to SharedTemplate objects with feature-type definitions, enabling a single API surface for both layer templates and datastore shared templates.
Edit data from a branch version
Edits can be made to service feature tables from a branch versionServiceFeatureTable. You can also follow the process described above for adding, deleting, and updating features or their attachments.