11

I am trying to clip or filter lidar files (.las, .xyz) using a shapefile that contains multiple polygons.

Is there open source software that can do this spatial operation?

My .las files are enormous, and I should say that I am very new to DEM data and analysis so any help would be very welcome.

4
  • 1
    SAGA GIS also offers some tools to process LiDAR datasets, but I have no direct experience with them. SAGA is completely free and opensource so just try it :-)
    – Juhele
    Commented Feb 11, 2014 at 11:09
  • 1
    +1 for SAGA. I completely missed that one. In SAGA, there is a module called point cloud cutter, which can also clip by shape extent: "This modules allows to extract subsets from a Point Cloud. The area-of-interest is defined either by bounding box coordinates, the extent of a grid system or a shapes layer, or by polygons of a shapes layer." There are modules for other filtering tasks as well.
    – lavarider
    Commented Feb 11, 2014 at 11:17
  • 1
    ty for your time andre, my final goal is to edit those clipped points and build a new las. Commented Feb 12, 2014 at 7:28
  • ty for your responses , you all helped me a lot and as michal and andre said, FUSION did the trick. Commented Feb 14, 2014 at 23:55

5 Answers 5

9

FUSION LiDAR Toolkit has clipping capabilities (PolyClipData tool) and unlike LASTools, its usage is unrestricted. However, despite the fact that some SVN repository on SourceForge exists, the source code published is incomplete and very old. If you can proceed without knowing the code and just use the compiled binary, then FUSION should be fine for this task.

3
8

I second @Michal Mackiewicz's answer (about Fusion/LTK), so I hope this example helps you getting through it.

This is the PolyCLipData syntax command (see the manual's page 110):

PolyClipData [switches] PolyFile OutputFile DataFile

Use an text editor to write the command before running it (such as NotePad++). Save the file with extension .bat (batch file). Don't forget to save the file before running it.

Assume you have:

  1. Fusion/LTK under the C: drive.
  2. the shapefile file (shapefile.shp) under C:\shapefile
  3. the las dataset (lasdata.las) under C:\las

write the following:

c:\fusion\polyclipdata c:\shapefile\shapefile.shp c:\las\clipped_data.las c:\las\lasdata.las

use the switch multifile if you want the las files generated from polygons to be stored in separate files. For example:

c:\fusion\polyclipdata /multifile c:\shapefile\shapefile.shp c:\las\clipped_data.las c:\las\lasdata.las 

use the shape switch together with multifile to name your multiple OutputFiles with values embedded in one of PolyFile's dbf column. For example if you want to name the files with the ID information (suppose ID is in the shapefile's first column). Write:

c:\fusion\polyclipdata /multifile /shape:1,* c:\shapefile\shapefile.shp c:\las\clipped_data.las c:\las\lasdata.las 

For clipping las files using PolyClipData with multiple single part shapefiles see the following post:
Clipping LAS data with multiple shapefiles

For clipping multiple las files having them embedded in a .txt file as the datafile parameter for PolyClipData, refer to the following post:
Clip multiple .las files data to polygon shapefile using FUSION

For clipping multiple las files with shapefiles using (with the LAStools Production toolbox) refer to the following post:
Clipping from a tiled LAS dataset with LASTools (for ArcGIS)

0
3

Various different filtering tasks are commonly applied to LiDAR datasets (filtering by point density, low pass, vegetation filtering, smoothing-tasks and so on). As you are asking for a spatial operation (involving a shapefile), I assume you look for a way to clip your dataset, i.e. exclude points that are outside of polygon boundaries defined by a shapefile.

Generally, LAStools is a powerful package for point data processing. It is a set of command-line tools, but also brings a simple GUI and integrates with QGIS (and ArcGIS, by the way). You can freely download and evaluate the toolbox - however, only parts of it are open source (LGPL 2.1 licence) - the closed-source parts require licensing depending on your purpose. You have to check what conditions apply for you.

Use lasclip from LASTools (closed-source, check licensing)

One of the closed-source tools, lasclip, exactly performs a clip-by-shapefile task:

lasclip: takes as input a LAS/LAZ/TXT file and a SHP/TXT file with one or many polygons (e.g. building footprints), clips away all the points that fall outside all polygons (or inside some polygons), and stores the surviving points to the output LAS/LAZ/TXT file.

Usage is straightforward:

lasclip -i input_file.las -poly polygons.shp -o output_file.las -verbose

(check the lasclip README for further details upon usage, more examples and shapefile requirements)

Use las2las from LASTools (open-source; basic clipping tasks only)

If closed-source software is not an option: the las2las tool can perform simple clipping tasks as well - however, you cannot clip to a shapefile-defined polygon. You can clip by rectangles, circles, elevation, scan angle, classification or data quality for example. (See its README for usage examples and details.)
Unfortunately, I am not aware of any open-source tool which equals the lasclip functionality.

Use libLAS to access LAS files in a self-made script

LASTools are based on the open-source, BSD-licensed libLAS library. You could use libLAS to access your LAS files and filter them with a custom script, e.g. using Python.

Of course there are other possibilities if you change your processing flow (e.g. converting LAS to raster and clip later), but I think the most convenient way is to keep working with LAS as long as possible and perform all the filtering with the point cloud data itself.

1
  • ty lavarider for responding, ive seen lasclip , it is what im looking for but closed source is not an option , las2las force me to go over the shapes on my shapefile , it leave me with liblas , and with the other solutions here i will check it and post back Commented Feb 11, 2014 at 17:28
3

WhiteboxTools can clip a LAS file to multiple polygons contained within a Shapefile using the ClipLidarToPolygon tool. Using Python scripting, you can use the tool as follows:

from WBT.whitebox_tools import WhiteboxTools

wbt = WhiteboxTools()

wbt.work_dir = "/path/to/data/"
wbt.clip_lidar_to_polygon(i="input.las", polygons="polygons.shp", ouput="ouput.las")

Or, if you prefer a GUI, you may use the QGIS based plugin or the WhiteboxTools Runner, which is distributed (wb_runner.py) with the binary download of the library:

WhiteboxTools Runner ClipLidarToPolygon tool

2

I have written a step-by-step PDAL tutorial that demonstrates how to do this task in that environment. Please see the PDAL clipping tutorial for more information.

1
  • I could not acess the hyperlink now (had acessed before), but even if it is because of my device; edit in at least the relevant part of the code which does the clipping. Of course having a complente tutorial in PDAL’ s website is nice, but answers shouldn’t be based only on external sources. Commented Jan 7, 2019 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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