|
本帖最后由 qspillxj1983 于 2018-2-22 14:35 编辑
基于PYTHON读取EXECL坐标坐标批量生成面
import xlrd,xlwt,arcpy,os
xlsPath = arcpy.GetParameterAsText(0)
polPath = arcpy.GetParameterAsText(1)
path = os.path.dirname(polPath)
outputname = os.path.basename(polPath)
# 新建一个空的面要素图层
arcpy.CreateFeatureclass_management(path, outputname,"POLYGON")
arcpy.management.AddField(outputname,"bh","text",18,"","")
arcpy.management.AddField(outputname,"Name","text",18,"","")
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(outputname)
for i in range(1,nrows):
str = table.cell(i,3).value
bh = table.cell(i,4).value
name = table.cell(i,1).value
points = str.split(';')#这里代表范围坐标里面的坐标是以";"来进行分割的,根据坐标的不同可以修改这里
for j in points:
xy = j.split(',') #这里代表范围坐标里面的每个XY坐标是用“,”分割的
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)
*****************************************************************************
print xy[0]
print xy[1]
print '\n'
point.X = float(xy[0]);
point.Y = float(xy[1])#当EXECL表里面的范围坐标字段的XY坐标是反转过来的话,那么只需要将这里修改一下就行了,修改为如下代码
视频地址:ARCGIS中使用PYTHON读取EXECL坐标点数据生成多边形面图层
|
评分
-
查看全部评分
|