使用ArcGIS字段计算器计算要素的拐点坐标(线,面要素)
打开字段计算器,如下图,选择python,显示代码块,粘贴以下代码。dd=GetpointXY( !Shape! ),参数选Shape字段。
确定
代码块如下:
def GetpointXY(feat):
partnum = 0
# Count the number of points in the current multipart feature
partcount = feat.partCount
pntcount = 0
# Enter while loop for each part in the feature (if a singlepart
# feature this will occur only once)
pointxy=""
while partnum < partcount:
part = feat.getPart(partnum)
pointxy+=str(partnum+1)+":"
pnt = part.next()
# Enter while loop for each vertex
while pnt:
pntcount += 1
if pnt:
pointxy+=str(pntcount)+":"+str(pnt.X)+","+str(pnt.Y)+";"
pnt = part.next()
# If pnt is null, either the part is finished or there
# is an interior ring
#
if not pnt:
pnt = part.next()
partnum += 1
return pointxy
注意:字段长度要设长一些,如果超限的话会执行不了。