2 Star 1 Fork 3

changjiang128/tiles_pnts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
custom_tiler.py 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
changjiang128 提交于 2022-12-23 07:07 . update custom_tiler.py.
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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/changjiang128/tiles_pnts.git
git@gitee.com:changjiang128/tiles_pnts.git
changjiang128
tiles_pnts
tiles_pnts
master

搜索帮助