Удалить пространственные объекты (Delete Features) (Управление данными (Data Management))

Уровень лицензии:BasicStandardAdvanced

Краткая информация

Удаляет все пространственные объекты или выбранный их поднабор из входного набора данных.

Если входные объекты принадлежат классу пространственных объектов или таблице, то будут удалены все строки. Если входные объекты принадлежат слою без выбранных элементов, то будут удалены все объекты.

Использование

Синтаксис

DeleteFeatures_management (in_features)
ПараметрОбъяснениеТип данных
in_features

Класс пространственных объектов, шейп-файл или слой с объектами, которые требуется удалить.

Feature Layer

Пример кода

Пример DeleteFeatures 1 (окно Python)

Пример скрипта Python для инструмента DeleteFeatures с запуском из окна Python в мгновенном режиме.

import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.CopyFeatures_management("majorrds.shp", "C:/output/output.gdb/majorrds2")
arcpy.DeleteFeatures_management("C:/output/output.gdb/majorrds2")
Пример DeleteFeatures 2 (автономный скрипт)

Пример скрипта Python для выполнения инструмента Удалить объекты (DeleteFeatures), чтобы удалить объекты с учетом выражения.

# Name: DeleteFeatures_Example2.py
# Description: Delete features from a feature class based on an expression
 
# Import system modules
import arcpy
from arcpy import env
 
# Set environment settings
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 as e:
    # If an error occurred, print line number and error message
    import traceback
    import sys
    tb = sys.exc_info()[2]
    print("Line {0}".format(tb.tb_lineno))
    print(e.message)

Параметры среды

Экстент (Extent)

Удаляются только объекты, расположенные внутри или экстента или на его пересечении.

Связанные темы

Информация о лицензировании

ArcGIS for Desktop Basic: Да
ArcGIS for Desktop Standard: Да
ArcGIS for Desktop Advanced: Да
5/10/2014