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.
{ "pipeline":[ "autzen.laz", { "type":"filters.crop", "polygon": "Polygon ((638500.66904077248182148 853359.34703735215589404, 638869.71793351718224585 853365.15883093187585473, 638881.34152069012634456 853208.24040409235749394, 638677.92874516302254051 853199.52271371346432716, 638878.43562390014994889 852818.85023379256017506, 638733.14078423334285617 852842.09740813483949751, 638611.09311891463585198 852975.76866063219495118, 638416.39803376235067844 853211.14630088687408715, 638500.66904077248182148 853359.34703735215589404))" }, { "type":"writers.las", "filename":"file-cropped.las" } ] }
Note:
- 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.
No comments:
Post a Comment