0

我是 Python 的初学者,发现了一些我想测试的代码,因为似乎没有什么对我有用:

import numpy as np
import laspy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# reading las file and copy points
input_las = laspy.read("topography.las")
point_records = input_las.points.copy()

# getting scaling and offset parameters
las_scaleX = input_las.header.scale[0]
las_offsetX = input_las.header.offset[0]
las_scaleY = input_las.header.scale[1]
las_offsetY = input_las.header.offset[1]
las_scaleZ = input_las.header.scale[2]
las_offsetZ = input_las.header.offset[2]

# calculating coordinates
p_X = np.array((point_records['point']['X'] * las_scaleX) + las_offsetX)
p_Y = np.array((point_records['point']['Y'] * las_scaleY) + las_offsetY)
p_Z = np.array((point_records['point']['Z'] * las_scaleZ) + las_offsetZ)

# plotting points
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(p_X, p_Y, p_Z, "marker=o")
plt.show()

在大多数情况下,我的 IDE 似乎没有抛出任何错误。但是说它缺少 .copy .points 等的一些文档。另外,当我运行代码时,我得到:

Traceback (most recent call last):

line 19, in <module>
    p_X = np.array((point_records['point']['X'] * las_scaleX) + las_offsetX)

和:

line 185, in __getitem__
    return self.array[item]
ValueError: no field of name point

我究竟做错了什么?我试图适应的代码:https ://gis.stackexchange.com/questions/277317/visualizing-las-with-matplotlib

4

0 回答 0