ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Delete Features

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Deletes all or the selected subset of features from the input.

If the input features are from a feature class or table, all rows will be deleted. If the input features are from a layer with no selection, all features will be deleted.

Usage

  • This tool accepts layers with selections as input and will delete only those features that are selected. To delete specific features from a feature class, convert the feature class into a layer using Make Feature Layer or by adding it to the ArcMap display. A selection can then be applied using the Select Layer By Attribute or Select Layer By Location tools or by querying a map layer or selecting features with the selection arrow in ArcMap.

  • If a layer is input, and that layer does not have a selection, all features will be deleted. If a feature class is input, all features will be deleted.

    Note:

    Deleting all rows from a feature class with a large number of rows can be slow. If your intent is to delete all the rows in the feature class you should consider using the Truncate Table tool instead. See the Truncate Table documentation for important cautionary statements on its use.

  • This tool deletes both the geometry and attributes of the Input Features.

  • The Output Extent environment is honored by this tool. Only the features that are within or intersect the output extent environment will be deleted. If the input layer has a selection, only the selected features that are within or intersect the output extent will be deleted.

  • When using a layer with selections as input, using this tool in an edit session will allow for the Delete Features operation to be undone using undo/redo.

Syntax

DeleteFeatures_management (in_features)
ParameterExplanationData Type
in_features

The feature class, shapefile, or layer containing features to be deleted.

Feature Layer

Code sample

DeleteFeatures example 1 (Python window)

The following Python window script demonstrates how to use the DeleteFeatures tool in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.CopyFeatures_management("majorrds.shp", "C:/output/output.gdb/majorrds2")
arcpy.DeleteFeatures_management("C:/output/output.gdb/majorrds2")
DeleteFeatures example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the DeleteFeatures tool to delete features based on an expression.

# Name: DeleteFeatures_Example2.py
# Description: Delete features from a feature class based on an expression
 
# Import system modules
import arcpy
 
# Set environment settings
arcpy.env.workspace = "C:/data/airport.gdb"
 
# Set local variables
inFeatures = "parcels"
outFeatures = "C:/output/output.gdb/new_parcels"
tempLayer = "parcelsLayer"
expression = arcpy.AddFieldDelimiters(tempLayer, "PARCEL_ID") + " = 'Cemetery'"
 
try:
    # Execute CopyFeatures to make a new copy of the feature class
    arcpy.CopyFeatures_management(inFeatures, outFeatures)
 
    # Execute MakeFeatureLayer
    arcpy.MakeFeatureLayer_management(outFeatures, tempLayer)
 
    # Execute SelectLayerByAttribute to determine which features to delete
    arcpy.SelectLayerByAttribute_management(tempLayer, "NEW_SELECTION", 
                                            expression)
 
    # Execute GetCount and if some features have been selected, then 
    #  execute DeleteFeatures to remove the selected features.
    if int(arcpy.GetCount_management(tempLayer).getOutput(0)) > 0:
        arcpy.DeleteFeatures_management(tempLayer)
         
except Exception:
    e = sys.exc_info()[1]
    arcpy.AddError(e.args[0])

Environments

  • Current Workspace
  • Extent
    Note:

    Only those features that are within or intersect the extent will be deleted.

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Features toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal