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 12:12:40 浏览: 107
使用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()
# 选择导出数据路径
output_path = arcpy.GetParameterAsText(2)
# 导出数据
arcpy.FeatureClassToFeatureClass_conversion(feature_class, output_path)
# 完成操作并清理内存
del cursor
阅读全文