Hot answers tagged

8

You should check what the scale and offset are for your file. This can be done as follows: van_taken.header.scale van_taken.header.offset This almost looks like an overflow error to me. The lower case x, y, and z properties need to re-scale and re-offset the coordinates to store it as an integer (which is how LAS files store them). To be honest, setting ...


7

Rather than setting the entire points array in one go, try setting each dimension in turn: import laspy header = laspy.header.Header() outfile = laspy.file.File("output.las", mode="w", header=header) outfile.X = [1, 2, 3] outfile.Y = [0, 0, 0] outfile.Z = [10, 10, 11] outfile.close()


4

According to this page, Laspy supports LAS/LAZ versions 1.0-1.4. Looking at the Laspy code, it looks like the format string "h6.0" would correspond to a version "1.6" of the spec. A value of "6" for the format corresponds to a specific predefined header format. (See the code, or the following link, for clarification on what that means) There's a good ...


4

I was able to come up with a solution. The following code works, but it feels like there is a much simpler way to do this operation. If anyone has a cleaner or more efficiect way to filter and reclassify lidar with laspy I'd love to accept that answer. import laspy import numpy as np from scipy.spatial import cKDTree in_file = laspy.file.File(input_file, ...


4

Laspy isn't going to give you convenient access to the SRS in a form you can easily consume. LAS files can have either WKT or GeoTIFF keys as the coordinate system description. For consumption in Esri tools (and elsewhere), you always want the WKT. The most convenient way to get the WKT from an LAS file is to use PDAL. The following script will read a ...


4

The header needs to be set with a point format that supports RGB colors, see: https://pythonhosted.org/laspy/tut_background.html. For LAS 1.2, the minimum point format for color is 2: header = laspy.header.Header(point_format=2) # LAS point format 2 supports color with laspy.file.File(output_path, mode="w", header=header) as lasfile: lasfile.header....


4

You should use min and max property of header. from laspy.file import File f = File("path/to/file.laz", mode='r') h = f.header # h.min: [min_x, min_y, min_z] - h.max: [max_x, max_y, max_z] extent = [*h.min, *h.max] # extent: [min_x, min_y, min_z, max_x, max_y, max_z]


3

LAS 1.2 has a classification byte, which is 8 bits. However 3 of those bits are used for the flags (withheld, synthetic, and keypoint). With laspy, classification accesses the 5 bits that LAS 1.2 allows for the classification number. 2^5 is 32, meaning you can store 32 classes (0-31) in that 5-bit integer. It doesn't touch the flag bits. ...


3

This is a working solution with laspy: 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.file.File("test.las", mode="r") point_records = input_las.points.copy() # getting scaling and offset parameters las_scaleX = input_las.header.scale[0] ...


3

So, is there a better way, more efficient, more pythonesque way of injecting the .las file points (from laspy) to the GeoPandas dataframe without passing through a numpy array? No, and I'm not sure why you think this is the least efficient way to go. laspy is underneath the covers making a memoryview to the data and the Numpy array is a wrapper over that. ...


2

OK, I think I've solved my problem. The issue is noted at the github page for laspy here: https://github.com/grantbrown/laspy/issues/51 I needed to adjust the "start_first_evlr" property to be the full length of the LAS file as shown below. Not sure if that is the best way, but it seems to work. I needed to read the mmap size for the input LAS file (before ...


2

The latest version of laspy will generate default file_sig = 'LASF', version_major = 1, version_minor = 2 and data_format_id = 0. However, the header offset and scale have to be specified. The following code (modified adamp's code) can generate output.las which can be read and then displayed using CloudCompare and QT Reader (The QT Reader needs minimum 4 ...


2

Since this question was asked, that cryptic error message from laspy was improved. Update to the latest laspy and try again, you should get a more informative error message.


2

The issue was that I was not using the set method from laspy writer. I modified the Outfile.red to outfile.set_red. This makes a nice las 1.2 file from scratch. Working code: def write_las(self, point_array, filename, info): #Creates las files for the calculated points and rawpoints try: red, green, blue = info classify =...


2

There is some kind of a recession with the latest numpy. See https://github.com/laspy/laspy/issues/112#issuecomment-583180711 for details.


2

Turns out all you have to do is to change X, Y, Z to not be capital letters like this. outFile.x = trees[:, 0] outFile.y = trees[:, 1] outFile.z = trees[:, 2]


2

As determined while working through the problem with Aaron, I figured out I was working with corrupt data, because applying the same code to other .las file worked (here is the alternative file used). I have opened another question related to why FUSION is creating corrupt data when using the polyclipdata module here: FUSION polyclipdata creates corrupt ...


1

https://github.com/grantbrown/laspy says Laspy is a pythonic library for reading, modifying and writing LAS files. Support for LAZ is limited to reading LAS version 1.0-1.3 files. laspy does not have support for writing files in the LAZ format.


1

You should be using lower-case letters for the dimensions when accessing them as floats, e.g. outfile.x instead of outfile.X. The capitalized version is used to access the "un-scaled" dimension, which are the integers that are stored internally. Lower case should apply the scaling for you when accessing them. In your case, you're actually ...


1

Yogi,You can check here -https://github.com/laspy/laspy/commit/4dba4c846eacf119b5e99ccf8ccae73735ef1944. You need to write the points to an numpy array first and then write the array(X's, y's and Z's) to the file. Read a few million points at a time and make smaller las files that you can eventually join together to make a much more massive file. If you ...


1

I ran into the same error with las files containing EXTRA_BYTE information generated with lasheight from LAStools. After removing the EXTRA_BYTE information laspy had no issue to open the files.


Only top voted, non community-wiki answers of a minimum length are eligible