Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Untwine to avoid LAS / LAZ Shuffle in custom attributes #56942

Closed
2 tasks done
vincentBenet opened this issue Mar 22, 2024 · 4 comments
Closed
2 tasks done

Update Untwine to avoid LAS / LAZ Shuffle in custom attributes #56942

vincentBenet opened this issue Mar 22, 2024 · 4 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Point Clouds Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...)

Comments

@vincentBenet
Copy link

vincentBenet commented Mar 22, 2024

[Linked to Laspy issue: https://github.com/laspy/laspy/issues/311]

What is the bug or the crash?

Custom attributs are shuffle when LAZ file is open by QGIS. File are created using laspy package.

The shuffle seems to depends on the number of attributes, OS and QGIS version.
image
image

Steps to reproduce the issue

  1. Create a LAS file using laspy having multiple custom attributes.
def reproduct_issue(path: Path) -> None:
    header = laspy.LasHeader(point_format=3, version="1.4")
    las = laspy.LasData(header)
    las.add_extra_dims(
        [
            laspy.ExtraBytesParams(name="b", type=np.float64),
            laspy.ExtraBytesParams(name="bx", type=np.float64),
            laspy.ExtraBytesParams(name="by", type=np.float64),
            laspy.ExtraBytesParams(name="bz", type=np.float64),
        ],
    )
    las.x = np.linspace(0, 100, 100)
    las.y = np.linspace(0, 100, 100)
    las.z = np.linspace(0, 100, 100)
    las.b = np.full(100, 0, dtype=np.float64)
    las.bx = np.full(100, 1, dtype=np.float64)
    las.by = np.full(100, 2, dtype=np.float64)
    las.bz = np.full(100, 3, dtype=np.float64)
    las.write(str(path), laz_backend=laspy.LazBackend.LazrsParallel)
  1. Open the file using QGIS with drag'n drop

  2. Open a point attributs and see error with shuffle values

  3. By opening theses values with laspy the order is correct:

las = laspy.read(str(path))
>>> las.points[0].b
0.0
>>> las.points[0].bx
1.0
>>> las.points[0].by
2.0
>>> las.points[0].bz
3.0

Versions

QGIS 3.34.5 LTS
laspy 2.5.3

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

LAS & LAZ files : files.zip

@vincentBenet vincentBenet added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Mar 22, 2024
@hobu
Copy link

hobu commented May 2, 2024

I suspect this might be the Untwine version that's being used. I tested it in

laspy/laspy#311

using the latest Untwine hobuinc/untwine@255d30b and it works as expected.

@vincentBenet
Copy link
Author

vincentBenet commented May 2, 2024

Nice @hobu !
If I understand correctly, you have runned QGIS with modified source code and having untwine version updated.
By doing so, the shuffle is not present anymore when you drag'n drop the las file in QGIS layer panel ?

@hobu
Copy link

hobu commented May 2, 2024

I did not test QGIS at all, just Untwine which is what QGIS uses to create the COPC file when you drag-n-drop data onto it. I suspect the version of QGIS you are using is using an older version of Untwine that may have had issues with extra byte dimensions. I hope one of the QGIS devs can report what Untwine version is currently used by QGIS 3.34.5 LTS.

@vincentBenet vincentBenet changed the title LAS / LAZ Shuffle in custom attributes Update Untwine to avoid LAS / LAZ Shuffle in custom attributes May 29, 2024
@uclaros uclaros added the Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...) label Jul 5, 2024
@uclaros
Copy link
Contributor

uclaros commented Jul 5, 2024

Apparently the 3.34 branch is using a version of untwine that is a couple commits before v1.0.0 ...
I wouldn't vouch for backporting latest untwine to the lts branch, especially after the changes in classFlags handling.

I'm closing this as it's both fixed upstream and pulled into latest qgis version 3.38

@uclaros uclaros closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Point Clouds Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...)
Projects
None yet
Development

No branches or pull requests

4 participants