Giter VIP home page Giter VIP logo

Comments (7)

FlorianStasse avatar FlorianStasse commented on July 25, 2024 1

Here is a function to easily reproduce the issue:

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)

I'm using laspy 2.5.3 and Qgis LTS 3.34.5 to open the exported file.

If you open the exported file, you will see that the additional fileds do not have the expected value.

from laspy.

hobu avatar hobu commented on July 25, 2024 1

Using the following example script to create a file and then running it through Untwine@hobuinc/untwine@255d30b, I do not see any mix ups in the data values and their extra_bytes definitions.

import laspy
import numpy as np

# 0. Creating some dummy data
my_data_xx, my_data_yy = np.meshgrid(np.linspace(-20, 20, 15), np.linspace(-20, 20, 15))
my_data_zz = my_data_xx ** 2 + 0.25 * my_data_yy ** 2
my_data = np.hstack((my_data_xx.reshape((-1, 1)), my_data_yy.reshape((-1, 1)), my_data_zz.reshape((-1, 1))))

# 1. Create a new header
import pyproj
header = laspy.LasHeader(point_format=6, version="1.4")
header.add_crs(pyproj.CRS("EPSG:4326"))
header.add_extra_dim(laspy.ExtraBytesParams(name="random24", type=np.int32))
header.add_extra_dim(laspy.ExtraBytesParams(name="random42", type=np.int32))
header.add_extra_dim(laspy.ExtraBytesParams(name="random24f", type=np.float64))
header.add_extra_dim(laspy.ExtraBytesParams(name="random42f", type=np.float64))
header.offsets = np.min(my_data, axis=0)
header.scales = np.array([0.1, 0.1, 0.1])

# 2. Create a Las
las = laspy.LasData(header)

las.x = my_data[:, 0]
las.y = my_data[:, 1]
las.z = my_data[:, 2]
las.random42 = np.full(len(las.points), 42, np.int32)
las.random24 = np.full(len(las.points), 24, np.int32)
las.random42f = np.full(len(las.points), 42.0, np.float64)
las.random24f = np.full(len(las.points), 24.0, np.float64)

las.write("new_file.las")

from laspy.

hobu avatar hobu commented on July 25, 2024

I don't understand what you mean by 'shuffle'.

from laspy.

vincentBenet avatar vincentBenet commented on July 25, 2024

I am using laspy to display magnetic survey by drone. On each point I have custom attributes "b", "bx", "by", "bz"

But once processed trought laspy, on QGIS, all "bz" values will be in "by" insteed.

Here is the script used that is shuffle values:

def write_mag(path: Path, data: npt.NDArray[np.float_], epsg_proj: int) -> None:
    header = laspy.LasHeader(point_format=3, version="1.4")
    header.add_crs(pyproj.CRS(f"EPSG:{epsg_proj}"))
    las = laspy.LasData(header)
    las.add_extra_dims(
        [
            laspy.ExtraBytesParams(name="bx", type=data["bx"].dtype),
            laspy.ExtraBytesParams(name="by", type=data["by"].dtype),
            laspy.ExtraBytesParams(name="bz", type=data["bz"].dtype),
            laspy.ExtraBytesParams(name="b", type=data["b"].dtype),
        ],
    )
    las.x = data["x"]
    las.y = data["y"]
    las.z = data["z"]
    las.bx = data["bx"]
    las.by = data["by"]
    las.bz = data["bz"]
    las.b = data["b"]
    las.write(str(path), laz_backend=laspy.LazBackend.LazrsParallel)
    logger.info("Wrote LAS file to %s", path)

Values are "f8" numpy types.

from laspy.

hobu avatar hobu commented on July 25, 2024

So is this a QGIS ticket or a laspy ticket?

from laspy.

vincentBenet avatar vincentBenet commented on July 25, 2024

This is both as I don t know where the problem come from...
qgis/QGIS#56942

from laspy.

vincentBenet avatar vincentBenet commented on July 25, 2024

Yes, after more investigation it seems laspy is doing a great job. But QGIS doesn't.
This software will create a .copc.laz file where the attributes will shuffles...

from laspy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.