arcgis python xlstoshp
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
=======================================修改===================================================
import xlrd # must init xlrd import arcpy import os # param arcpy.env.workspace = r"F:\kktemp" #workspace excelPath = r"sss.xlsx" # excel file path excelTableIndex = 0 # excel's table index outName = r"F:\kktemp\point.shp" # out file fileName=r'F:\kktemp\sss.xlsx' if os.path.exists(fileName): excel = xlrd.open_workbook(fileName) # 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('Xian_1980_3_Degree_GK_CM_111E') 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) pointGeometryList.append(pointGeometry) arcpy.CopyFeatures_management(pointGeometryList,outName) # save the shape file