mreutegg / laszip4j

The LASzip library ported to Java
GNU Lesser General Public License v2.1
35 stars 16 forks source link

LASPoint returns wrong coordinates + NullPointerException #153

Open Nathipha opened 1 month ago

Nathipha commented 1 month ago

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 commented 4 weeks ago

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?