Skip to content

Commit 99c7d3c

Browse files
authored
Upgrade the api to laspy 2.0 (#330)
* Upgrade the api to laspy 2.0 * Update requirements.txt and setup.py
1 parent 4d7928c commit 99c7d3c

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

pyntcloud/io/las.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ def convert_color_to_dtype(data, output_dtype):
4545

4646
def read_las_with_laspy(filename):
4747
if laspy is None:
48-
raise ImportError("laspy is needed for reading .las files.")
48+
raise ImportError("laspy (>=2.0) is needed for reading .las files.")
4949
data = {}
50-
with laspy.file.File(filename) as las:
51-
data["points"] = pd.DataFrame(las.points["point"])
50+
with laspy.open(filename) as las_file:
51+
las = las_file.read()
52+
data["points"] = pd.DataFrame(las.points.array)
5253
data["points"].columns = (x.lower() for x in data["points"].columns)
5354
# because laspy do something strange with scale
54-
data["points"].loc[:, ["x", "y", "z"]] *= las.header.scale
55+
data["points"].loc[:, ["x", "y", "z"]] *= las.header.scales
5556
data["las_header"] = las.header
5657
return data
5758

@@ -70,7 +71,7 @@ def read_las_with_pylas(filename):
7071
return data
7172

7273

73-
def read_las(filename, xyz_dtype="float32", rgb_dtype="uint8", backend="pylas"):
74+
def read_las(filename, xyz_dtype="float32", rgb_dtype="uint8", backend="laspy"):
7475
"""Read a .las/laz file and store elements in pandas DataFrame.
7576
7677
Parameters

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
numpy
22
scipy
33
pandas
4-
pylas
4+
laspy
55
lazrs
66
ipython
77
matplotlib

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"pandas",
2525
],
2626
extras_require={
27-
'LAS': ["pylas", "lazrs"],
27+
'LAS': ["laspy", "lazrs"],
2828
'PLOT': ["ipython", "matplotlib", "pyvista>=0.32.0"],
2929
'NUMBA': ["numba"]
3030
},

0 commit comments

Comments
 (0)