概述
以下脚本是直接在ArcGIS中的python IDLE中编写代码,可以选择在vsc中编写
以下脚本 这段代码节选自yGIS-csdn
其中 windows路径下的 转义符问题(已修正)
import arcpy, sys
month = ["feb","mar","may","jun","jul","aug","oct","nov","dec"]
for part in range(8):
for m in month:
try:
path = r"G:AthrunArcDataPoint"
outputname = str(part)+"_"+str(m)+"_quanzhou.shp"
spatRef = arcpy.SpatialReference(4326)
createFC=arcpy.CreateFeatureclass_management(path, outputname, "POINT", "","","", spatRef)
arcpy.AddField_management(path+"\"+outputname, "NAME", "TEXT", 50)
iflds = ["NAME","SHAPE@XY"]
#iCur = arcpy.da.InsertCursor(createFC, iflds)
iCur = arcpy.da.InsertCursor(path+"\"+outputname, iflds)
count = 1
for ln in open(('F:\quanzhou_ship\'+str(m)+'\'+str(part)+r'_quanzhou_'+str(m)+'.csv'), 'r').readlines():
lnstrip = ln.strip()
if count > 1:
dataList = ln.split(",")
lat = dataList[15]
lon = dataList[16]
id = dataList[0]
ivals = [id,(float(lon), float(lat)) ]
iCur.insertRow(ivals)
count += 1
del iCur
except EnvironmentError as e:
tbE = sys.exc_info()[2]
print("Failed at Line {}n".format(tbE.tb_lineno))
print("Error: {}".format(str(e)))
except Exception as e:
tbE = sys.exc_info()[2]
print("Failed at Line {}n".format(tbE.tb_lineno))
print("Error: {}".format(e.message))
最后
以上就是甜美苗条为你收集整理的ArcPy --读取CSV格式的XY坐标并转成shp文件的全部内容,希望文章能够帮你解决ArcPy --读取CSV格式的XY坐标并转成shp文件所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复