An implement based on C++ and LAStools read and write las file. In this way, if LAStools changes a lot, you do not need to change you kernel code.
For the Las IO, there is no dependency, for the Las projection converter, it depends on GDAL.
#! /bin/bash
mkdir build
cd build
cmake ..
make
This version only imports read and write uncompress las file.
This version only imports read compress/uncompress las file and write uncompress las file.
Read the "extended number of point records" for the LAS1.4 file.
This version add the gps time in the structure, an other change is that use the submodule LAStools in the code, so that the code can be changed with the LAStools in the later.
There are some files need to be removed in Linux :
./rmfile.sh
Some code need to be added in "laswriter_las.hpp" and "laswriter_las.cpp".
The code is easy to use, here is an example for reader :
// define the path
char szSrcLas[512] = "";
CWuLasLib srcLas;
srcLas.Open(szSrcLas);
int nPoints = srcLas.GetPtNum();
DPT3D * pLas = new DPT3D[nPoints];
memset(pLas, 0, sizeof(DPT3D) * nPoints);
srcLas.ReadLas(pLas, nPoints);
double xOffset = 0;
double yOffset = 0;
double zOffset = 0;
srcLas.GetOffset(xOffset, yOffset, zOffset);
double xPrecision = 0;
double yPrecision = 0;
double zPrecision = 0;
srcLas.GetPrecision(xPrecision, yPrecision, zPrecision);
srcLas.Close();
There are two example in the example folder:
- LasFileExample is an example to crop the las file. After compiling the code, there is a test example in the data folder:
#! /bin/bash
./LasFileExample "../data/Vaihingen_Strip_10-sub.LAS" "../data/Vaihingen_Strip_10-cut.LAS" 497020 5420320 497040 5420420
- LasFileConvert is a tool to convert the Las file using GDAL, the projection file should be in proj4 format. In the data folder, there are two files, i.e 3943_CC43.proj4 and 2154_Lambert93.proj4, these files can be downloaded from EPSG.
Download proj4 file |
There is a testing example in the data folder:
#! /bin/bash
./LasFileConvert "../data/3943_CC43.las" "../data/3943_CC43.proj4" "../data/2154_Lambert93.proj4" "../data/3943_CC43_convert.las"
After converting, the the result has the same coordinate reference with 2154_Lambert93.las, then you can visualize them in CloudCompare:
Visulization in CloudCompare |
In the figure, the red points(3943_CC43_convert.las) are converted data, this data is from AI4GEO project. And the white points(2154_Lambert93.las) are from UMBRA data.
It is useful to use LAStools to analyze the LAS file, for example :
#! /bin/bash
lasinfo -i file.las
If you think you have any problem, contact [Teng Wu][email protected]