HOW TO
In ArcGIS Online, a feature can be deleted from a hosted feature layer in Map Viewer. However, features can only be deleted one at a time. Deleting multiple features, all features, or features based on attributes is not possible.
This article provides four different workarounds to perform batch deletion of features from a hosted feature layer.
Use one of the four workarounds below to batch delete features from a hosted feature layer.
Note: These workarounds may take a longer processing time when deleting a large number of records.
Delete features using the Delete Features operation from the ArcGIS REST API
Multiple features can be deleted by the Object IDs using the Delete Features operation from the ArcGIS REST API. Refer to FAQ: Is it possible to batch delete features in ArcGIS Online? for instructions.
However, running the operation with non-existing Object IDs does not return an error message. The result is returned as successful even when no feature is deleted in the operation. In this example, the Object ID, '50' is not in the feature layer, but the operation is indicated as successful.
The Where parameter in the Delete Features operation can also be configured with WHERE clauses to query features and delete them from the feature layer.
Note: The result, 'None' is displayed in the Delete Results section if the Where parameter is configured with non-existing Object IDs.
Below are examples of how the WHERE clause can be utilized when using the Delete Features operation.
OBJECTID > 4 AND OBJECTID < 10
Population > 5000 AND Population < 150000
1=1
Delete all features using the Truncate operation from the ArcGIS REST API
Note: The following restrictions apply when performing the Truncate operation: • It cannot be used when the layer is an origin in relationships with other layers. • It cannot be used to truncate layers that reference the same underlying database tables. • It cannot be used when sync is enabled.
Use the Truncate operation instead of the Delete Features operation when working with a large dataset. To access the operation, modify the REST URL by appending '/admin' between /rest and /services, and '/truncate' between /<layerID> and ?token as shown in the image below.
https://services.arcgis.com/<OrganizationID>/ArcGIS/rest/admin/services/<serviceName>/FeatureServer/<layerId>/truncate?token=<Token>
The Truncate operation supports deleting layer features with the attachments or the attachments in a layer only. Refer to the 'Request parameters' section in ArcGIS REST APIs: Truncate (Feature Layer) for more information on the parameters.
Note: It is recommended to set ASync to True for larger datasets.
Batch delete the features in ArcMap or ArcGIS Pro
Open the hosted feature layer in ArcMap or ArcGIS Pro to select and delete the desired features. To edit the hosted feature layer in ArcMap, refer to ArcMap: About editing data from feature services, ArcMap: Using Select By Attributes, and ArcMap: Deleting a feature for more information.
For batch deletion of features from a hosted feature layer in ArcGIS Pro, refer to How To: Batch delete features from a hosted feature layer in ArcGIS Pro and ArcGIS Pro: Select features by attributes for instructions.
Overwrite the existing feature layer
Use ArcGIS Pro to overwrite the existing web feature layer in ArcGIS Online with an empty layer of the same schema. However, when overwriting the web feature layer, its associated data is replaced. For example, changes to the pop-ups or symbology, or any other updates to the web layer after it is initially published, are lost. Refer to ArcGIS Pro: Overwrite a web feature layer for more information. The image below is the dialog box displaying the cautionary message related to overwriting a web layer.
Get help from ArcGIS experts
Download the Esri Support App