import arcpy import os import sys feature_class = arcpy.GetParameterAsText(0) query = arcpy.GetParameterAsText(1) output_path = arcpy.GetParameterAsText(2) if not arcpy.Exists(output_path): arcpy.CreateFolder_management(os.path.dirname(output_path), os.path.basename(output_path)) gdb_path = os.path.join(output_path, "output.gdb") if not arcpy.Exists(gdb_path): arcpy.CreateFileGDB_management(output_path, "output.gdb", "CURRENT") expression = arcpy.AddFieldDelimiters(feature_class, "SHAPE_Area") + " < " + query if arcpy.Exists(feature_class): count = arcpy.GetCount_management(feature_class) if int(count.getOutput(0)) == 0: print("要素类为空,不需要进行操作") else: with arcpy.da.UpdateCursor(feature_class, "*", where_clause=expression) as cursor: for row in cursor: cursor.deleteRow() arcpy.FeatureClassToFeatureClass_conversion(feature_class, gdb_path, "output_feature_class", where_clause=expression) print("操作完成") else: print("要素类不存在")运行错误:SyntaxError: EOL while scanning string literal (批量删除小面积.py, line 21) 执行(删除小面)失败。请改正代码
时间: 2023-12-30 10:03:23 浏览: 128
使用arcpy获取简单的矢量数据信息.zip_arcPy 查询_arcpy 数据读入_arcpy 读取数据_arcpy矢量拼接
这个错误通常是由于字符串中缺少引号或括号引起的。在你的代码中,第21行最后缺少一个右括号。请检查你的代码并添加缺失的右括号,例如:
```
arcpy.FeatureClassToFeatureClass_conversion(feature_class, gdb_path, "output_feature_class", where_clause=expression)
```
同时,还要检查你的代码是否存在其他的语法错误或拼写错误。
阅读全文