vtkLASReader()

Hi,
I saw somewhere that vtk has a reader for .las files (lidar data) (vtkLASReader) but when I try to use it it says that there is no such attribute. What am I missing ?

Can you share your data?

You can also try vtkPDALReader which should be more complete.

Dan

FYI: Here is a function using laspy and vtki to read LAS point clouds I made.

The vtkLASReader is only available if VTK is compiled with an option for it (not sure about the details). I’ve been working with a lot of point clouds lately and I needed to use the VTK module available on PyPI so I made this snippet.

Note that vtki is simply a helper module for VTK - the returned poly object is an instance of vtk.vtkPolyData

from laspy.file import File
import numpy as np
import vtki

def read_las(filename):
    """Reads a LAS lidar point cloud to vtkPolyData"""
    inFile = File(filename, mode='r')
    I = inFile.Classification == 2
    points = np.c_[inFile.X, inFile.Y, inFile.Z][I]
    inFile.close()
    poly = vtki.PolyData(points)
    poly.point_arrays['intensity'] = inFile.Intensity[I]
    poly.point_arrays['classification'] = inFile.Classification[I]
    poly.set_active_scalar('intensity')
    return poly

Hi,
Thank you for your answers. I decided to use your script Bane, it works perfectly.

1 Like

Glad to hear, @clairecita! Would you please mark that comment as the solution to close this thread

Also, this might be of interest to you when I merge it into vtki: https://github.com/vtkiorg/vtki/pull/128

And this thread as well Eye-Dome Lighting: vtkEDLShading (example request)