arcpy创建带高程的点图层
def createShpFromTxt(txtPath,outPath): #打开txt文件 allLine = [] with open(txtPath,'r') as file: #按行读取 for line in file: #存储到列表中 allLine.append(line) #创建坐标系 spatialReference = arcpy.SpatialReference(4326) #创建矢量图层 fc=arcpy.CreateFeatureclass_management( r"D:","test.shp", "POINT", "", "","ENABLED", "") #添加矢量字段 arcpy.AddField_management(outPath, "bianhao", "TEXT") #获得向矢量中插入点要素的指针 cursor = arcpy.InsertCursor(fc, ["SHAPE@XY"]) #遍历存储所有行的列表 for oneline in allLine: #根据存储结构,按逗号分割字符串 line=oneline.split(',') #新建一行 feature = cursor.newRow() #创建新的点要素 #pt=(line[2],line[3]) vertex = arcpy.CreateObject("Point") # print vertex.Z #设置点要素的X坐标 vertex.X = line[2] # 设置点要素的Y坐标 vertex.Y =line[3] vertex.Z=line[4] #将新建的点要素赋值给新建的一行 feature.shape = vertex # #添加属性 feature.bianhao =line[1] #保存到矢量文件中 cursor.insertRow(feature) del cursor del fc
转载自:https://blog.csdn.net/A873054267/article/details/88207732