ARCGIS读取Excell数据生成多边形Python脚本


import xlrd,xlwt,arcpy
... xlsPath = r'F:\Lot.xls'
... data = xlrd.open_workbook(xlsPath)  
... table = data.sheets()[0]#通过索引顺序获取  
... cols = table.col_values(3) 
... nrows = table.nrows
... point = arcpy.Point()
... array = arcpy.Array() 
... polygonGeometryList = [] 
... cur =  arcpy.InsertCursor("d:\\polygon.shp")
... for i in range(1,nrows): 
...     str = table.cell(i,3).value
...     name = table.cell(i,2).value
...     points = str.split(';')
...     for j in points:
...         xy = j.split(',') 
...         print xy[0] 
...         print xy[1]
...         print '\n'  
...         point.X = float(xy[0]);
...         point.Y = float(xy[1])
...         array.add(point)
...     row = cur.newRow()
...     row.shape = array
...     row.name = name
...     array.removeAll() 
...     cur.insertRow(row)

转载自:https://blog.csdn.net/qq_34069180/article/details/78058108

You may also like...