• 注册
当前位置:1313e > python >正文

python点shp密度分析_使用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")

效果图如下:

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 162202241@qq.com 举报,一经查实,本站将立刻删除。

最新评论

欢迎您发表评论:

请登录之后再进行评论

登录