天天看点

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

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