22

I have been using FUSION and the command line FUSION Lidar Toolkit (LTK) to process LiDAR data. A broad Google search ("Lidar Python") yielded libLAS and pyLAS as Python LiDAR libraries, however, these appear to provide only read and write access to LAS data.

I am particularly interested in creating intensity and density images in addition to canopy surface models from point clouds. Is there a generally accepted set of tools in Python that can accomplish the same sort of tasks FUSION LTK is capable of?

  • 1
    It is not a direct answer to your question, but as I've been working on a Python software for the reconstruction of botanical trees from LIDAR-acquired point cloud data, perhaps the technology stack I've been using could give you some ideas. In particular, the visualization layer is built using VTK, which is very powerful. – cjauvin Mar 3 '14 at 20:15
  • ArcMap 10.1 has ultilities to handle Lidar Datacloud filters for display and analysis with other layers. C++ is probably the best method to handle the data rich .las files as recommended above. – user28345 Mar 21 '14 at 17:18
  • I don't see how this answer's the OP's question. He wants a tool in Python. If you are suggesting C++, you should back up that claim with a detailed reason. – Devdatta Tengshe Mar 22 '14 at 16:31
13

laspy is another good LAS read/write software. It supports working with the data directly in numpy arrays and a number of other nice Pythonic features. It isn't processing software per se, however.

PDAL has the ability to use Python as an in-pipeline filtering language, but this isn't a processing engine either.

There isn't too much in the Python quiver for LiDAR and point cloud processing. I think some of this has to do with the volumes of data typically processed and the typical response to reach for C/C++ when faced with the challenge. I do hope that as Python improves (PyPy is driving lots of things, and it is the reason that I worked to have laspy developed) more Python point cloud processing software becomes available. I think the outlook is improving but things still aren't quite there yet.

7

I have recently released an open-source (MIT) stand-alone (i.e. no dependencies) library called WhiteboxTools for performing many types of geospatial analysis, including LiDAR data processing. The library is written in Rust and has extensive support for Python-based scripting. For example, the following Python script uses the WhiteboxTools library to populate the RGB colour data of LiDAR points in a LAS file:

from whitebox_tools import WhiteboxTools

wbt = WhiteboxTools()
wbt.work_dir = "/path/to/data/"
in_lidar = "lidar_data.las"
in_image = "airphoto.tif"
out_lidar = "colourized_lidar.las"
wbt.lidar_colourize(in_lidar, in_image, out_lidar) 

The LiDAR-specific processing tools of WhiteboxTools include the following functions:

  • BlockMaximum: Creates a block-maximum raster from an input LAS file.
  • BlockMinimum: Creates a block-minimum raster from an input LAS file.
  • FilterLidarScanAngles: Removes points in a LAS file with scan angles greater than a threshold.
  • FindFlightlineEdgePoints: Identifies points along a flightline's edge in a LAS file.
  • FlightlineOverlap: Reads a LiDAR (LAS) point file and outputs a raster containing the number of overlapping flight lines in each grid cell.
  • LidarElevationSlice: Outputs all of the points within a LiDAR (LAS) point file that lie between a specified elevation range.
  • LasToAscii: Converts one or more LAS files into ASCII text files.
  • LidarColourize: Adds the red-green-blue colour fields of a LiDAR (LAS) file based on an input image.
  • LidarGroundPointFilter: Identifies ground points within LiDAR dataset.
  • LidarIdwInterpolation: Interpolates LAS files using an inverse-distance weighted (IDW) scheme.
  • LidarHillshade: Calculates a hillshade value for points within a LAS file and stores these data in the RGB field.
  • LidarHistogram: Creates a histogram from LiDAR data.
  • LidarInfo: Prints information about a LiDAR (LAS) dataset, including header, point return frequency, and classification data and information about the variable length records (VLRs) and geokeys.
  • LidarJoin: Joins multiple LiDAR (LAS) files into a single LAS file.
  • LidarKappaIndex: Performs a kappa index of agreement (KIA) analysis on the classifications of two LAS files.
  • LidarNearestNeighbourGridding: Grids LAS files using nearest-neighbour scheme.
  • LidarPointDensity: Calculates the spatial pattern of point density for a LiDAR data set.
  • LidarPointStats: Creates several rasters summarizing the distribution of LAS point data.
  • LidarRemoveDuplicates: Removes duplicate points from a LiDAR data set.
  • LidarRemoveOutliers: Removes outliers (high and low points) in a LiDAR point cloud.
  • LidarSegmentation: Segments a LiDAR point cloud based on normal vectors.
  • LidarSegmentationBasedFilter: Identifies ground points within LiDAR point clouds using a segmentation based approach.
  • LidarTile: Tiles a LiDAR LAS file into multiple LAS files.
  • LidarTophatTransform: Performs a white top-hat transform on a Lidar dataset; as an estimate of height above ground, this is useful for modelling the vegetation canopy.
  • NormalVectors: Calculates normal vectors for points within a LAS file and stores these data (XYZ vector components) in the RGB field.

Additionally, there are numerous tools for processing the DEMs that are interpolated from LiDAR source data (e.g. feature-preserving denoising, hydro enforcement, etc). Details can be found in the User Manual. Source code can be found here, and the compiled binaries are on the Geomorphometry and Hydrogeomatics website, here.

  • Wow! Looking forward to testing these tools out. – Aaron Mar 21 '18 at 1:37
  • I hope that it work out for you. Just email me if you have any questions. – WhiteboxDev Mar 21 '18 at 11:05
  • I assume LidarPointStats is similar to FUSION's GridMetrics? Is there any documentation in which grid metrics are created when using LidarPointStats? – Aaron Mar 21 '18 at 20:01
  • @Aaron I'm not too sure about FUSION's tool since I've never used the software, but this tool outputs the following: num_points, num_pulses, z_range, intensity_range, predom_class. Details can be found here (github.com/jblindsay/whitebox-geospatial-analysis-tools/blob/…) and also in the user manual. – WhiteboxDev Mar 21 '18 at 22:20
  • @Aaron I probably should also have clarified that the lidar_point_stats tool tool is reporting each of those stats on a cell-by-cell basis. That is, there is a raster produced for each of the stats that the user specifies as a desired output. For example: lidar_point_stats('input.las', resolution=1.0, num_points=True, num_pulses=True) – WhiteboxDev Mar 21 '18 at 22:27
2

Although not strictly a 'Python' library but rather a set of wrappers for other tools, in particular GRASS, there are the 'ARSF DEM Scripts' which I have written:

https://github.com/pmlrsg/arsf_dem_scripts

One of the aims was to provide a common set of Python functions for different command line tools (called using subprocess) with a method flag used to specify the tool.

Example usage to generate a DSM, intensity and density image is:

from arsf_dem import dem_lidar

# DSM image (GRASS, points2grid, SPDLib, FUSION or licensed LAStools)
dem_lidar.las_to_dsm('in_las.las', 'out_dsm.tif',
                      method='points2grid')

# Intensity image (GRASS or licensed version of LAStools)
dem_lidar.las_to_intensity('in_las.las', 'out_intensity.tif',
                           method='GRASS')

# Density image (GRASS only)
dem_lidar.grass_lidar.las_to_density('in_las.las', 'out_density.tif',
                                     bin_size=10)

There are quite a few LiDAR processing tools available through the GRASS Python wrapper which could also be used instead of / in addition to what is available through arsf_dem.

2

pylidar is a relatively new set of Python modules for LiDAR processing. It is based on SPDLib and RIOS and uses numpy.

It is available for download from here

2

Starting to play around with tools found here. Its been quite useful. https://github.com/brycefrank/pyfor

  • Excellent link! I am especially looking forward to playing with the grid metrics. – Aaron Nov 27 '18 at 1:03
1

If you look at the source code of the QGIS toolbox for LAStools (now part of the processing plugin framework) you can see how to call external software (here LAStools) for carrying out LiDAR processing operations.

Not the answer you're looking for? Browse other questions tagged or ask your own question.