Run traceback errors and missing documentation

65 Views Asked by At

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

0

There are 0 best solutions below