Working with LAS and PCD Files¶
It’s possible to read pointcloud files with the format .las and .pcd. In order to read them just the submodule PointCloud.from_file():
[ ]:
from pathlib import Path
import laspy
import numpy as np
import pointcloudset as pcs
[ ]:
testpcd = Path().cwd().parent.joinpath("../../../tests/testdata/las_files/test_tree.pcd")
testlas = testpcd = Path().cwd().parent.joinpath("../../../tests/testdata/las_files/test_tree.las")
[ ]:
las_pc = pcs.PointCloud.from_file(testlas)
pcd_pc = pcs.PointCloud.from_file(testpcd)
Note:¶
Coordinates might not be correct yet, since the offset and scale values that are stored within the .las-file are not applied. But now you can use the data as a pcs.PointCloud and analyze + edit it.
[ ]:
las_pc.data
[ ]:
las_pc.plot(color="z")
Combining them to a pointcloudset dataset¶
You can combine multiple single PointCloud together with a timestep to a pointcloudset dataset.
[ ]:
dataset = pcs.Dataset.from_instance("pointclouds", [las_pc, pcd_pc])
Now you have a regular Pointcloudset Dataset. Note that the timestamps are taken from the pointcloud objects, which by default are the file timestamp.
[ ]:
dataset.timestamps
[ ]:
las_pc.timestamp
[ ]:
dataset.mean()
[ ]:
dataset[0].plot()
[ ]:
dataset[1].plot()
Exporting of Las¶
you can currently export single pointclouds to las and csv. For the supported formats see:
[ ]:
pcs.io.POINTCLOUD_TO_FILE
[ ]:
dataset[0].to_file(Path("test_tree_export.las"))