The cropping can be done using PDAL's crop filter but it requires the cropping polygon to be specified in the Well Known Text (WKT) string format. This is a bit of pain but can be overcome using a few methods, one of which is shown below using QGIS and the Plain Geometry Editor plugin.
Define the cropping polygon
- In QGIS, draw a new polygon e.g. mask, as shown below.
Note: The mask should be created in the same coordinate system as the LAS file.
- Click the Plain Geometry Editor icon in the toolbar (red circle above). Click on the clipping polygon.
The Plain Geometry Editor dialog box appears.
Note: Install the Plain Geometry Editor plugin if the icon is not available.
- In the text field, select and copy all the polygon WKT text string into the Windows clipboard.
Create a PDAL processing pipeline JSON file
- In a text editor, type in something similar to the example below.
- From the Windows Clipboard, paste the WKT string from the previous section to the "polygon" attribute and surround it with double quote '"' characters.
- Save the JSON file e.g. process.json.
- The pipeline JSON file stores the processes to be done in sequence in an array bracketed by the '[' and ']' characters.
- autzen.laz is the input LAS file for this example
- filters.crop is the process to apply using the "polygon" attribute.
- file-cropped.las is the output LAS file.
Run the cropping process
- Open up the OSGeo4W Shell.
- At the prompt, type in the pdal pipeline command:
C:\> pdal pipeline process.json -v 4
Processing messages appear. The file is cropped.
- Optional. Using your preferred LAS Viewer, open up the resultant cropped LAS file.
The cropped file showing only the cropped area is displayed.