Clipping LAS data using shapefile polygons and open source software?
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.
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:
- Fusion/LTK under the C: drive.
- the shapefile file (shapefile.shp) under C:\shapefile
- 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 lastools (with the LAStools Production
toolbox) refer to the following post:
Clipping from a tiled LAS dataset with LASTools (for ArcGIS)
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: