arcgis python xlstoshp

时间秒杀一切 提交于 2019-11-27 08:36:23
import xlrd # must init xlrd 
import arcpy

# param
arcpy.env.workspace = r"F:\note\python\ArcPy" #workspace
excelPath = r"test.xlsx" # excel file path
excelTableIndex = 0 # excel's table index
outName = r"point.shp" # out file

excel = xlrd.open_workbook('test.xlsx') # get excel
table = excel.sheets()[0] # get table by sheets index
nrows = table.nrows # number of table's row
# get data
pointGeometryList = [] # a list to hold the PointGeometry objects
point = arcpy.Point() #create an empty Point object
spRef = arcpy.SpatialReference('WGS84 ARC System Zone 18')

for i in range(1,nrows): # get row once
    x = table.cell(i,0).value 
    y = table.cell(i,1).value
    point.X = float(x)
    point.Y = float(y)
    pointGeometry = arcpy.PointGeometry(point,spRef)
    pointGeometryList.append(pointGeometry)

arcpy.CopyFeatures_management(pointGeometryList,outName) # save the shape file
--------------------- 
版权声明:本文为CSDN博主「PasserQi」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/summer_dew/article/details/78116722

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!