您的位置:首页 > 编程语言 > Python开发

ArcGIS10.1 python 提取面的所有拐点坐标到属性字段中

2013-04-08 14:33 369 查看
      也许你会有这样的需求,是要把面数据的所有拐点坐标提取出来存储到一个属性字段中使用,但是又不想大费周折的写一些AO、AE甚至是addin的程序,那么你可以选择是哟个python来完成你的工作。示例代码如下,在arcgis10.1中通过测试

def MySub(feat):   

 partnum = 0

 #multipart feature

 partcount = feat.partCount

 pntcount = 0

 str=''

 # Enter while loop for each part in the feature (if a singlepart feature

 # this will occur only once)

 while partnum < partcount:

  part = feat.getPart(partnum)

  pnt = part.next()

  # Enter while loop for each vertex

  #

  str=str+"["

  while pnt:

   pntcount += 1

   px='%f' %pnt.x

   py='%f' %pnt.y

   str=str+px+","+py +";"

   pnt = part.next()

  

   # If pnt is null, either the part is finished or there is an

   # interior ring

   if not pnt:

    str=str[:-1]

    str=str+"]"

    pnt = part.next()

  partnum += 1

 return str
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: