The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

9

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 ...


6

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

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....


3

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 ...


2

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

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 ...


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 makeLASfile(finishPoints,LASheader, valuesP): #From laspy print("Your Making LAS file") outfile = laspy.file.File("C:\\Users\\Cary Hutchinson\\Documents\\Programming\\...


2

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] ...


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