import re,arcpy
from arcpy import env
env.workspace = 'E:\\bao1'#%%工作空间
#reader=open('','r')#打开点的txt文件
s=arcpy.GetParameterAsText(0)
s=s.split('\\')[-1]
inputname=s.split('.')[0]
reader=open(arcpy.GetParameterAsText(0))
prjFile=arcpy.GetParameterAsText(1)
pat=re.compile('<coordinates>.*</coordinates>')
while True:
line=reader.readline()
if len(line)==0:
break
line=line.strip()#删除首位空格
m=pat.match(line)
if m:
corstr=line
corstr=corstr.strip()
reader.close()
corstr=re.sub('<coordinates>(.*?)</coordinates>',r'\1',corstr)
coordilst=corstr.split(',')
coordilst=[float(a) for a in coordilst]
point=arcpy.Point()
point.X=coordilst[0]
point.Y=coordilst[1]
pointGeometry=arcpy.PointGeometry(point,prjFile)
outputname=inputname+'.shp'
arcpy.CopyFeatures_management(pointGeometry,outputname)
arcpy.AddField_management(outputname,'Name','TEXT',9,'','','Name','NULLABLE','REQUIRED')
rows=arcpy.UpdateCursor(outputname)
for row in rows:
row.Name=inputname
rows.updateRow(row)
del row,rows
arcpy.SetParameter(2,outputname)
在这里插入代码片
读取googel earth 点坐标
最新推荐文章于 2024-06-10 10:00:00 发布