激光点云数据格式Las/Laz目前网上流行的读取库为c++版本的LibLas,java版本的读取解析工具目前还没有找到,但是还好有大神已经为java程序员打了LibLas的JNI版本(https://github.com/jsimomaa/LASlibJNI),比较可惜的是只封装了读取方法未提供写方法,但是对于点云数据来说我们大多都是需要读取他的数据进行相关处理,已经满足大多数情景。

import org.lastools.LASHeader;
import org.lastools.LASPoint;
import org.lastools.LASReader;
import org.lastools.LASlibJNI;

public static void main(String [] args) {
    // Initialize the native library
    LASlibJNI.initialize();
    
    // Get an instance of LASReader for provided file
    try (LASReader reader = new LASReader("src/test/resources/1.0_0.las")) {
    
        // Get the header information of the file
        LASheader header = reader.getHeader();
        
        // Check that the file is supported and in tact
        if (header.check()) {
            // Ok, read points
            while (reader.readPoint()) {
                LASPoint point = reader.getPoint();
                double x = point.getX();
                double y = point.getY();
                double z = point.getZ();
                System.out.println(x + y + z);
            }
        }
    }
}