HOW TO

Batch delete features from an ArcGIS Online hosted feature layer

Last Published: February 24, 2023

Summary

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.

Procedure

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.

In the ArcGIS REST Services Directory page, under Delete Results for the Delete Features operation, the result for 'Success' is indicated as True even when Obejct ID 50 does not exist in the feature layer.

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.

  • Select features in a range of Object IDs using the AND or OR operators. For example, the following query is used to select and delete features under the Object IDs of 5, 6, 7, 8, and 9.
OBJECTID > 4 AND OBJECTID < 10
In the ArcGIS REST Services Directory page, under Delete Features operation, the query 'OBJECTID > 4 AND OBJECT < 10' is entered in the Where parameter.
  • Select features based on the values of other attribute fields. In this example, the field name is 'Population' and the following query is used to select and delete features with population counts that are higher than 5,000 and lower than 150,000.
Population > 5000 AND Population < 150000
In the ArcGIS REST Services Directory page, under Delete Features operation, the query 'Population > 5000 AND Population < 150000' is entered in the Where parameter.
  • Delete all the features in a feature layer. Enter the following query in the Where parameter to delete all the features.
1=1
In the ArcGIS REST Services Directory page, under Delete Features operation, the query '1=1' is entered in the Where parameter.

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 browser address tab showing the modified REST URL to access the Truncate operation.
The page of the Truncate operation under the ArcGIS REST Administrator Directory page. Parameters shown are Attachments Only, ASync, and Format.

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.

The dialog box displaying the cautionary message of overwriting a web layer in ArcGIS Pro.

Article ID: 000024111

Software:
  • ArcGIS Online
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcMap 10 6
  • ArcMap 10 7
  • ArcGIS Pro 2 x
  • ArcMap 10 8

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options