使用python读取矢量数据的坐标点如shp数据

在ArcGIS中复制出矢量数据如shp、FeatureClass的坐标节点是一件很麻烦的事情,通过arcpy等模块读取坐标点到文本中方便了许多。

#读取要素的坐标点,包括挖空地块的坐标点,输出到excel文件中,外圈使用1,内圈使用-1标识。
import arcpy
... import xlwt
... fc=r"F:\test.shp"
... cursor=arcpy.da.SearchCursor(fc,["OID@","字段1","字段2","SHAPE@"])
... xlsfile=xlwt.Workbook(encoding="utf-8")
... sht=xlsfile.add_sheet("sheet1","cell_overwrite_ok=True")
... rownum=0
... for feature in cursor:
...     if not feature[3]:
...         sht.write(rownum,0,feature[0])
...         sht.write(rownum,1,"空几何")
...         rownum=rownum+1
...         continue
...     else:
...         for pa in feature[3]:
...             j=0
...             bsm=1   
...             for pnt in pa:    
...                 if not pnt:
...                     bsm=-1
...                     j=0
...                     continue
...                 sht.write(rownum,0,feature[0])
...                 sht.write(rownum,1,feature[1])
...                 sht.write(rownum,2,feature[2])
...                 sht.write(rownum,3,j)
...                 sht.write(rownum,4,pnt.X)
...                 sht.write(rownum,5,pnt.Y)
...                 sht.write(rownum,6,bsm)
...                 rownum=rownum+1 
...                 j=j+1                                  
... xlsfile.save(r"F:\test.xls")

效果图如下:

 

转载于:https://www.cnblogs.com/apromise/p/10005778.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值