Showing posts with label lidar. Show all posts
Showing posts with label lidar. Show all posts

Thursday, April 4, 2013

Building Liblas for Win x64 with GDAL and Geotiff

Some things are obvious to even the most oblivious, how to get liblas from OSGeo4W is one of them. However you quickly run into trouble as images, dem files and las files get bigger and the 32 bit osgeo builds start causing issues. There have been some discussions regarding a 64 bit version of Osgeo4W but getting builders for all the packages probably hasn't been achieved yet. I will see if I can step in and fill my drive with source trees and wield my MSVC 2010 license for good rather than evil. It is now up on the OSGeo GSOC ideas page, may be someone will take it up and make GIS toolchain deployment easier.
Liblas install for OSGeo4W set-up
Anyway here is how to built Liblas, assuming you are reasonably familiar with downloading sources and clicking a few buttons in CMake GUI. Grab LibLAS 1.7.0 sources. Since we want to add image support, grab GDAL 64 bit builds with headers from GISInternals. Build Geotiff 64 bit by hand using the handy CMake system, pointing it to proj and tiff obtained from the GDAL build above. Grab Boost from the handy distribution in PCL, you can get it somewhere else but PCL was my last port of call for boost. The final Liblas config page in CMake should look something like below.
CMake Liblas config
Change CMakeLists.txt for LibLAS to include the boost chrono library, there are linker errors otherwise.

find_package(Boost 1.38 COMPONENTS program_options thread chrono REQUIRED)

MSVC 2010 Liblas project
Configure and build away. I use MSVC 2010 Professional, running the bigfile_test after building has finished creates a 4GB+ dummy .las file and is nice for checking the x64 version. Put all the dependency DLL's in place after the build has finished using the handy Dependency walker.
Dependency walker check for libraries
Most windows users do not have a compiler installed and the inability to get a GIS toolchain on windows which can handle large datasets beyond 32bit restrictions is a major stumbling block in the wider adoption of the OSGeo toolchain. You can grab my Liblas binaries here and if you are interested student looking to package for 64bit let  OSGeo know.

Wednesday, October 6, 2010

Processing Lidar with MPI - Liblas + MPICH2

I did some work in the last company for processing and reclassifying Lidar points using Liblas. The first Python implementation had lots of point-in-polygon queries and even with prepared geometries in GEOS took a few hours. We improved the execution of this by rasterizing the polygons, while polygons in theory have arbitrary precision and rasters are limited to the spacing they are gridded at, in this case the polygons were derived by classifying a rasterized version of the Lidar and the raster mask should have the same degree of precision.

The mask is overly generous in classes at times, considering each class as a local surface. A piecewise interpolation model can often be used to identify disparate points in context and perform class switching. In unordered Lidar data this may lead to many passes through the data generating neighbourhood class relationships if an index has not been built e.g. Octree.

I decided to adopt the Google philosophy of scale solves everything - and implemented the Lidar processing using MPI (Specifically MPICH2). The solution is implemented with task queues.
  1. Read all data on all nodes except last
  2. Node 0 makes a pass through all data sending each point in round robin to intermediate nodes
  3. Intermediate nodes receive a point and make another pass through all data identifying nearby points and using them in an IDW2 estimate
  4. Intermediate nodes message with IDW2 estimate to last node in the set (in charge of serializing) which makes various comparisons against classification masks (e.g. SRTM Water Boundary mask) and geo-statistical surface consistency before reclassifying and serializing to an output LAS file.
The task is essentially O(n^2) but with sufficient nodes we can bring it down to O(n*n/M+M*overheads) where M is the number of nodes. If the dataset is large enough and M is suitably chosen we gain significant speed increases. I got so carried away with Lidar + MPI ( and since I don't want to mix it with my PhD stuff) I started a small code dump on Google Code. Use CMake and see if you can build it. Lots of sample Lidar here.