Quantcast
Channel: Question and Answer » lidar
Viewing all articles
Browse latest Browse all 21

Use laspy to create las file from scratch without opening an existing las file first

$
0
0

I have found instructions for creating a las file by opening an existing file, modifying it, then re-saving it.

This re-uses the headers from the original file.

But how do I create a new file from scratch without loading another in the first place? I cannot see any documentation on the required format for the file, points, or headers.

I only need the bare minimum: x,y,z position for each point.

Here is how I assumed it might work…

import numpy as np
import laspy
import laspy.header
import laspy.file

points = []

#x,y,z values
points.append([0,0,10])
points.append([1,0,10])
points.append([2,0,11])

header = laspy.header.Header()
outFile = laspy.file.File("./output.las", mode = "w", header = header)
outFile.points = np.array(points)
outFile.close()

This fails with:

-> outFile.points = np.array(points)

/laspy/file.py
-> self._writer.set_points(new_points)

laspy/base.py
-> self.data_provider._pmap[:] = points[:]

ValueError: could not broadcast input array from shape (3,3) into shape (3)

Could anyone kindly point to some sample code or tips to get this working?


Viewing all articles
Browse latest Browse all 21

Trending Articles