-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Hello -
We have upgraded to the latest release of CloudComPy (February 20, 2024 -> June 19, 2025) and we have trouble saving LAS/LAZ clouds created from numpy arrays - The shift is not used when saving. The same issue does not occur for bin/xyz.
Without respecting the shift, the points overflow on save, with LAS header offset of saved file as [0,0,0].
What we want is to save out the file using the shift that was set.
To reproduce:
import numpy as np
import cloudComPy as cc
print("=== Create cloud ===")
points = np.array([[0.0, 0.0, 0.0]], dtype=np.float32)
cloud = cc.ccPointCloud("test")
cloud.coordsFromNPArray_copy(points)
cloud.setGlobalShift(0.0, -2_500_000.0, 0.0)
print("Shift:", cloud.getGlobalShift())
print("isShifted:", cloud.isShifted())
print("Points:", cloud.toNpArrayCopy())
print("=== Save ===")
cc.SavePointCloud(cloud, "test.las")
print("=== Load ===")
loaded = cc.loadPointCloud("test.las", mode=cc.CC_SHIFT_MODE.XYZ, x=0.0, y=-2_500_000.0, z=0.0)
print("Shift:", loaded.getGlobalShift())
print("isShifted:", loaded.isShifted())
print("Points:", loaded.toNpArrayCopy())
Output:
=== Create cloud ===
Shift: (0.0, -2500000.0, 0.0)
isShifted: True
Points: [[0. 0. 0.]]
=== Save ===
=== Load ===
Shift: (0.0, -2500000.0, 0.0)
isShifted: True
Points: [[ 0. -4647483.5 0. ]] ## Should be [0,0,0]
LAS saving works when I load/save a cloud that already has an appropriate shift in the header.
Possibly related to the expanded options in CloudCompare that suggests can look at the LAS header instead of the set shift when saving:
https://www.cloudcompare.org/forum/viewtopic.php?p=30162#p30162
Appreciate any ideas or short-term fixes.