Using lidR, given a LAS object, read from a LAS file:
las <- readLAS(point_cloud_file)
and points (extracted from a shapefile):
shp <- st_read(shp_file)
pts <- st_coordinates(shp)
I would like to add (append) these points to the LAS object (assuming both las
and shp
share the same CRS)
How can I get to that?
Best Answer
This is not as easy as it might seem. From
pts
which is amatrix
you can extract the columns. Here I'm usingrunif
to make a reproducible exampleThen we can make a
LAS
object withLAS()
and we provide the header oflas
to create object of the same formatThis triggers some warning because we input some inccorectly quantized coordinates. Check the output of
las_check()
We can fix that
Now if we want to combine the
las
andlas2
they must have the same columns. We need to make them manually. Here if you load onlyXYZ
inlas
the job is easier.We can bind the two objects