我想以 .las 格式保存一些文件,我找到了这段代码:
import laspy
import numpy as np
hdr = laspy.header.Header()
outfile = laspy.file.File("output.las", mode="w", header=hdr)
allx = np.array([1.000, 2.000, 3.000, 3.000]) # Four Points
ally = np.array([0.000, 0.000, 0.000, 3.000])
allz = np.array([10.000, 10.000, 11.000, 11.000])
xmin = np.floor(np.min(allx))
ymin = np.floor(np.min(ally))
zmin = np.floor(np.min(allz))
outfile.header.offset = [xmin,ymin,zmin]
outfile.header.scale = [0.001,0.001,0.001]
outfile.x = allx
outfile.y = ally
outfile.z = allz
outfile.close()
这可以正常工作但这是针对仅具有XYZ值的数据,如何为具有 XYZ 标签值的数据编写此内容???...我的源数据集是 *.txt 格式。