0

I am trying to plot a las file with one million points in Matplotlib. When I try to plot the file it always gives me a blank result.

This is the code I am using:

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

# reading las file and copy points
input_las = laspy.read("C:\\split.las")
point_records = input_las.points.copy()

x_mask_g = np.array(point_records.X)
y_mask_g = np.array(point_records.Y)
z_mask_g = np.array(point_records.Z)

fig_surf_g = plt.figure()
ax = fig_surf_g.add_subplot(111, projection = '3d')
ax.plot_trisurf(x_mask_g, y_mask_g, z_mask_g)
plt.title("Ground Surface")
3

1 Answer 1

0

This works just fine. Obvisouly I use random data, so surface has no real elevation meaning. So, you might check that your input data is correct: data present, no tricky decimal separator, absence of "invalid data", "Not A Number" (NaN) etc.

enter image description here

import matplotlib.pyplot as plt
import numpy as np
# import laspy
import pandas as pd

# reading las file and copy points
# input_las = laspy.read("C:\\split.las")
# point_records = input_las.points.copy()

# create fake data since I do not have your data source at hand
df = pd.DataFrame(columns=["X", "Y", "Z"])
n = 1_000
df.X = np.random.uniform(low=-45, high=45, size=(n,))
df.Y = np.random.uniform(low=-179, high=180, size=(n,))
df.Z = np.random.uniform(low=-1000, high=9000, size=(n,))

x_mask_g = df.X.to_numpy()
y_mask_g = df.Y.to_numpy()
z_mask_g = df.Z.to_numpy()

fig_surf_g = plt.figure()
ax = fig_surf_g.add_subplot(111, projection='3d')
ax.plot_trisurf(x_mask_g, y_mask_g, z_mask_g)
plt.title("Ground Surface")
plt.show()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.