最近在学Arcpy顺带做了点线面要素转线要素的实验
arcpy一定要先下arcpy,然后在环境里面选择arcpy的py框架
以下为实验数据:

注意:运行程序时一定要关闭arcmap一定要!
(1)我先做的是点、线、面要素的特征点转换为文本文件
以下为脚本截图
以下为点矢量转txt文本
#coding:utf-8
import arcpy
txtPath = r"C:\Users\lenovo\Desktop\arcpy\test\points.txt"#不能识别汉字
shpPath = r"C:\Users\lenovo\Desktop\arcpy\test\点.shp"
with open(txtPath, "w") as filename:
cur = arcpy.SearchCursor(shpPath)
filename.write("Points" + "\n")
pointindex = 0
index = 0
for r in cur:
index=index+1
geom = r.shape
point = geom.getPart()
#for point in points:
info = str(pointindex) + " " + str(point.X) + " " + str(point.Y) + "\n"
filename.write((info))
pointindex = pointindex + 1
print index
print "finished"
此为线矢量转txt文本
#coding:utf-8
import arcpy
txtPath = r"C:\Users\leno

该博客分享了使用Python的Arcpy模块将点、线、面矢量要素转换为文本文件的实现过程。通过SearchCursor遍历要素,获取几何信息并写入文本,详细展示了点、线、面的转换脚本,强调了运行时需关闭ArcMap。
最低0.47元/天 解锁文章
1705

被折叠的 条评论
为什么被折叠?



