I am attempting to append .las files to another .las file using laspy. Basically, I have a collection of .las files that I need to merge into one large .las file (it's for input into a different software program). I have found the lasappender.py document, but am having a hard time parsing through the code. Does anyone know how to do this function? Any code snippets would be helpful.
Here is the code I have so far:
import os
import numpy as np
import laspy
import arcpy
import glob
try:
#folder with las files
workspace = 'C:/LidarServe/testing/python/input'
#get list of .las files
lasFiles = glob.glob(os.path.join(workspace, '*.las'))
print(lasFiles)
except:
print (arcpy.GetMessages())
#open las files list
with laspy.open(lasFiles[0], mode='a') as outlas:
with laspy.open(lasFiles) as inlas:
for points in inlas.chunk_iterator(2_000_000):
#append las files to lasFile[0]
outlas.append_points(points)
Here is the error message I am getting at this point in time:
AttributeError: 'list' object has no attribute 'read'
Best Answer
This code will append all of the las files to an existing las file. Be sure not to store the receiving las in the same directory as the folder of las files.
Here I have taken one of my las file and renamed the file to all_point.las and stored that file in another location. Then I append all of the las files in the directory to all_points.las. Tested on Python 3.6 on Ubuntu Linux (but it should run fine on Windows if Python is configured correctly).