代码拉取完成,页面将自动刷新
import laspy
import numpy as np
import progress as prog
from octree import node
from pyproj import CRS
from pyproj import Transformer
def clearTemps():
import os
if (os.path.exists("output/tmp")):
for f in os.listdir("output/tmp"):
if (f.endswith(".tmp")):
os.remove("output/tmp/" + f)
for f in os.listdir("output"):
if (f.endswith(".pnts") or f.endswith(".json")):
os.remove("output/" + f)
def comput_4978(epsg_in,points):
crs_in = CRS.from_epsg(epsg_in)
crs_out = CRS.from_epsg(4978)
transformer = Transformer.from_crs(crs_in,crs_out)
result_4978 = []
for index,value in enumerate(points):
item = transformer.transform(value[0],value[1],value[2])
result_4978.append(list(item))
return np.array(result_4978)
def loadFile():
# Clear temporary file content to facilitate repeated experiments
clearTemps()
f = laspy.read('./data/new_file.las')
points = np.vstack((f.x, f.y, f.z)).transpose()
print(points)
zuo = points[:,0:2]
you = points[:,2]
you = you +200
you = you.reshape(len(you),1)
points = np.concatenate((zuo,you),axis=1)
points = comput_4978(32649,points)
print("Coordinate conversion completed")
minBounds = list(np.min(points,axis=0))
maxBounds = list(np.max(points,axis=0))
# Repeated value processing of point cloud
print(len(np.unique(points,axis=1)))
length = len(points)
print("max boundary:"+str(minBounds)+'-->'+str(maxBounds))
count = 0
root_oct = node({'min': np.array(minBounds),
'max': np.array(maxBounds)})
for pnt in points:
x,y,z = pnt
p = {'x': x,
'y': y,
'z': z}
count += 1
root_oct.addPoint(p)
if (count % length//10 == 0):
prog.printProgressBar(count, length, 'Processing Octree')
print("octree end")
# Parent node downsampling, rewrite the tmp file
root_oct.write_tmp()
root_oct.writePnts()
root_oct.writeJson()
print("result")
if __name__ == '__main__':
loadFile()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。