import arcpy import sys # 获取要素类路径和查询条件 feature_class = arcpy.GetParameterAsText(0) query = arcpy.GetParameterAsText(1) if not arcpy.Exists(feature_class): arcpy.AddError("输入的要素类不存在!") sys.exit() # 构建查询语句 expression = arcpy.AddFieldDelimiters(feature_class, "SHAPE_Area") + " < " + query # 使用 arcpy.da.UpdateCursor 删除要素 with arcpy.da.UpdateCursor(feature_class, "*", where_clause=expression) as cursor: for row in cursor: cursor.deleteRow() # 完成操作并清理内存 del cursor请将代码加一个输出成果要素
时间: 2024-02-01 15:12:44 浏览: 136
使用arcpy获取简单的矢量数据信息.zip_arcPy 查询_arcpy 数据读入_arcpy 读取数据_arcpy矢量拼接
import arcpy
import sys
# 获取要素类路径和查询条件
feature_class = arcpy.GetParameterAsText(0)
query = arcpy.GetParameterAsText(1)
if not arcpy.Exists(feature_class):
arcpy.AddError("输入的要素类不存在!")
sys.exit()
# 构建查询语句
expression = arcpy.AddFieldDelimiters(feature_class, "SHAPE_Area") + " < " + query
# 使用 arcpy.da.UpdateCursor 删除要素
with arcpy.da.UpdateCursor(feature_class, "*", where_clause=expression) as cursor:
for row in cursor:
cursor.deleteRow()
# 输出成果要素
arcpy.AddMessage("要素删除成功!")
# 完成操作并清理内存
del cursor
阅读全文