KeyError: 'max_overlaps'

KeyError: 'max_overlaps'

参考:

http://blog.csdn.net/Bankeey/article/details/76691239

del files:

/media/lbg/Windows10/data/pascal_voc/cache

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
# coding=UTF-8 # This Python file uses the following encoding: utf-8 import arcpy # 设置工作空间和环境设置 arcpy.env.workspace = "D:/数据备份" # 设置工作空间路径 arcpy.env.overwriteOutput = True # 允许覆盖输出 # 定义线图层和点图层的名称 line_layer = r"D:\数据备份\线1.shp" # 替换为线图层的名称 point_layer = r"D:\数据备份\点.shp" # 替换为点图层的名称 # 创建一个用于存储要删除的节点的列表 nodes_to_delete = [] # 遍历线图层中的每个要素 with arcpy.da.UpdateCursor(line_layer, ["SHAPE@"]) as cursor: for row in cursor: line_geometry = row[0] # 获取线几何对象 # 检查线的起点和终点是否与点图层中的点重叠 start_point = line_geometry.firstPoint end_point = line_geometry.lastPoint start_point_overlaps = False end_point_overlaps = False with arcpy.da.SearchCursor(point_layer, ["SHAPE@"]) as point_cursor: for point_row in point_cursor: point_geometry = point_row[0] # 获取点几何对象 # 检查起点是否与点重叠 if start_point.within(point_geometry): start_point_overlaps = True break # 检查终点是否与点重叠 if end_point.within(point_geometry): end_point_overlaps = True break # 如果起点和终点都没有与点重叠,则将该要素的所有节点添加到要删除的列表中 if not start_point_overlaps and not end_point_overlaps: for i in range(1, line_geometry.pointCount - 1): nodes_to_delete.append(i) # 删除要删除的节点 with arcpy.da.UpdateCursor(line_layer, ["SHAPE@"]) as cursor: for row in cursor: line_geometry = row[0] # 获取线几何对象 # 创建一个新的 Polyline 对象 new_line_geometry = arcpy.Polyline() # 复制需要保留的节点到新的 Polyline 对象中 for i in range(line_geometry.pointCount): if i not in nodes_to_delete: new_line_geometry.addPoint(line_geometry.getPart(0).getObject(i)) # 更新要素 cursor.updateRow([new_line_geometry]) print("节点删除完成!")
最新发布
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值