arcgis几何修复有作用吗_修复几何 (数据管理)

RepairGeometry 示例 2(独立脚本)

以下独立脚本是如何在脚本中应用 RepairGeometry 函数的示例。

# Description:

# Goes through the table generated by the Check Geometry tool and does

# the following

# 1) backs-up all features which will be 'fixed' to a "_bad_geom" feature class

# 2) runs repairGeometry on all feature classes listed in the table

import arcpy

import os

# Table that was produced by Check Geometry tool

table = r"c:\temp\data.gdb\cg_sample1"

# Create local variables

fcs = []

# Loop through the table and get the list of fcs

for row in arcpy.da.SearchCursor(table, ("CLASS")):

# Get the class (feature class) from the cursor

if not row[0] in fcs:

fcs.append(row[0])

# Now loop through the fcs list, backup the bad geometries into fc + "_bad_geom"

# then repair the fc

print("> Processing {0} feature classes".format(len(fcs)))

for fc in fcs:

print("Processing " + fc)

lyr = 'temporary_layer'

if arcpy.Exists(lyr):

arcpy.Delete_management(lyr)

tv = "cg_table_view"

if arcpy.Exists(tv):

arcpy.Delete_management(tv)

arcpy.MakeTableView_management(table, tv, ("\"CLASS\" = '%s'" % fc))

arcpy.MakeFeatureLayer_management(fc, lyr)

arcpy.AddJoin_management(lyr, arcpy.Describe(lyr).OIDFieldName, tv, "FEATURE_ID")

arcpy.CopyFeatures_management(lyr, fc + "_bad_geom")

arcpy.RemoveJoin_management(lyr, os.path.basename(table))

arcpy.RepairGeometry_management(lyr)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值