运行回溯错误和缺少文档

发布于 2025-01-12 00:22:43 字数 1488 浏览 6 评论 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

I'm a beginner in Python, found some code that I wanted to test since nothing seems to work for me:

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()

for the most part seems like my IDE is not throwing any errors. But says it is missing some documentation for .copy .points and so on.
Also when I run the code I get:

Traceback (most recent call last):

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

and:

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

what am I doing wrong?
code I was trying to adapt: https://gis.stackexchange.com/questions/277317/visualizing-las-with-matplotlib

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文