判断图层管理器中是否存在某个图层

存在的图层名称,和图层类型
evLayerManager.isLayerExits( name , Cesium.EV_LayerType.IMAGE))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个示例代码,用于检查GDB各个图层的接边问题,并使用点图层标记接边错误: ```python import arcpy # 设置工作空间 arcpy.env.workspace = "path/to/your/gdb" # 获取所有的要素图层 feature_classes = arcpy.ListFeatureClasses() # 遍历所有的要素图层 for fc in feature_classes: # 获取要素图层的元数据 desc = arcpy.Describe(fc) # 如果要素图层是线图层 if desc.shapeType == "Polyline": # 创建点图层用于标记接边错误 point_fc = arcpy.CreateFeatureclass_management(arcpy.env.workspace, fc + "_points", "POINT") # 添加字段用于记录错误信息 arcpy.AddField_management(point_fc, "Error", "TEXT") # 遍历所有的线要素 with arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"]) as cursor: for row in cursor: oid = row[0] shape = row[1] # 检查线要素的起点和终点是否与其他线要素的起点或终点重合 start_point = shape.firstPoint end_point = shape.lastPoint start_point_check = arcpy.PointGeometry(start_point).buffer(0.1) end_point_check = arcpy.PointGeometry(end_point).buffer(0.1) # 遍历所有的线要素 with arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"]) as inner_cursor: for inner_row in inner_cursor: inner_oid = inner_row[0] inner_shape = inner_row[1] # 排除自身要素 if oid != inner_oid: inner_start_point = inner_shape.firstPoint inner_end_point = inner_shape.lastPoint # 判断起点是否重合 if start_point_check.contains(arcpy.PointGeometry(inner_start_point)) or start_point_check.contains(arcpy.PointGeometry(inner_end_point)): # 创建错误点要素 error_point = arcpy.PointGeometry(start_point) error_point_feature = arcpy.InsertCursor(point_fc).newRow() error_point_feature.setValue("Error", "Start point connection error with feature OID: " + str(inner_oid)) error_point_feature.Shape = error_point error_point_feature.OID = inner_oid arcpy.InsertCursor(point_fc).insertRow(error_point_feature) # 判断终点是否重合 if end_point_check.contains(arcpy.PointGeometry(inner_start_point)) or end_point_check.contains(arcpy.PointGeometry(inner_end_point)): # 创建错误点要素 error_point = arcpy.PointGeometry(end_point) error_point_feature = arcpy.InsertCursor(point_fc).newRow() error_point_feature.setValue("Error", "End point connection error with feature OID: " + str(inner_oid)) error_point_feature.Shape = error_point error_point_feature.OID = inner_oid arcpy.InsertCursor(point_fc).insertRow(error_point_feature) del cursor del inner_cursor ``` 这个示例代码可以检查所有的线图层,在检查过程,如果发现某个线要素的起点或终点与其他线要素的起点或终点重合,则在点图层创建一个错误点要素,并将错误信息记录在 "Error" 字段。最后,将点图层到该GDB下。请注意,这个示例代码只是一个简单的演示,需要根据实际情况进行修改和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值