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

LASPoint returns wrong coordinates + NullPointerException #153

Open
Nathipha opened this issue Oct 23, 2024 · 1 comment
Open

LASPoint returns wrong coordinates + NullPointerException #153

Nathipha opened this issue Oct 23, 2024 · 1 comment

Comments

@Nathipha
Copy link

I'm looking for all points within a certain rectangle with the following Java 8 code:

LASReader reader2 = reader.insideRectangle(641200, 5423150, 641210, 5423160);
Iterable<LASPoint> it = reader2.getPoints();
Iterator iterator = it.iterator();

if(iterator.hasNext()) {
    LASPoint p = (LASPoint) iterator.next();
    System.out.println(x="+p.getX()+", y="+p.getY()+", z="+p.getZ());
}

There are more than 1000 points and this prints:

x=-2996550, y=-3491960, z=-423220

Why are they negative numbers and how do I get access to the actual coordinates (x should be something like 641200)?

p.getXt() also throws a NullPointerException, even though at least the x and y coordinates in the .laz files should be doubles (z is probably stored as float).

@mreutegg
Copy link
Owner

getX(), getY() and getZ() return the raw value from the point data record. This value may be different from the actual value in the coordinate system, because the LAS header contains scale factors and offsets for each dimension.

See e.g. LASReaderTest.insideRectangle() for an example where coordinates seem to be off by a factor of 100, which is caused by the scale factor in the header.

Can you share the laz file that causes the NullPointerException?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants