import xlrd
import numpy
from tkinter import messagebox
path = r"C:\Users\Administrator\Desktop\杭州绕城西复平面.xls"
wb = xlrd.open_workbook(path)
ws = wb.sheet_by_index(0)
cordingDict = dict()
def rrd(point,f):
if f == 0:
point = str(int(f))
elif f>0:
SP = str(numpy.around(point,f))
sy = SP.split(".")
n = len(sy[1])
if n<f:
sj = f - n
point = sy[0]+"."+sy[1]+"0"*sj
else:
point = SP
elif f<0:
pass
return point
for n in range(ws.nrows):
cordingDict.update({ws.cell_value(n,0):""})
oP = list(cordingDict.keys())
with open(r"C:\Users\Administrator\Desktop\GC_XK.TXT","w") as f:
for vb in oP:
coordList = []
for n in range(ws.nrows):
cell = ws.row_values(n)
if vb == cell[0]:
coordList.append(cell)
coordX = 0
coordY = 0
coordZ = 0
for coord in coordList:
coordX += coord[1]
coordY += coord[2]
coordZ += coord[3]
ds = len(coordList)
x = coordX/ds
y = coordY/ds
z = coordZ/ds
for jc in coordList:
k = abs(x - jc[1])
hj = abs(y - jc[2])
kl = abs(z - jc[3])
if k > 0.011 or hj > 0.011 or kl > 0.011:
print("点号< %s >误差超限"%vb,k,hj,kl)
newCoord = [str(vb),",", rrd(x,3),",",rrd(y,3),",",rrd(z,3),"\n"]
f.writelines(newCoord)
f.close()
像控点取平均值
最新推荐文章于 2021-12-11 21:50:58 发布