Importing, Preprocessing, and Writing Data¶
To use pyforestscan, first import it in your Python project:
1 | |
Then, you can use it to load point cloud data and extract forest structure metrics.
The following sections will provide an overview of usage of the major functions of pyforestscan. For a complete reference of all functions in pyforestscan, please check the API documentation. For comprehensive examples of these functions, please see the example jupyter notebooks.
Importing Point Cloud Data¶
pyforestscan supports reading from the following point cloud data formats:
- las
- laz
- copc
- ept
and reading point clouds is done using the read_lidar function:
1 2 3 4 5 | |
Preprocessing Point Cloud Data¶
pyforestscan provides some basic functionality to help preprocess point cloud data. Many of these functions are wrapped PDAL routines. For example, to remove outliers and classify ground points:
1 2 3 4 | |
Adding Height Above Ground¶
Forest structure metrics require HeightAboveGround; raw elevation (Z) is not a substitute. If HeightAboveGround is not already present in your point cloud arrays, add it either while reading the data or afterward with add_height_above_ground. If you are reading directly from a point cloud file, you can calculate Height Above Ground during import:
1 2 3 4 5 | |
If your points are already in memory, use add_height_above_ground. The default method uses PDAL's Delaunay Height Above Ground filter and requires ground points classified as Classification == 2:
1 2 3 4 | |
You can also calculate Height Above Ground from a DTM raster. This method only requires X, Y, and Z fields in the point array, and the DTM must be in the same coordinate reference system as the points:
1 2 3 4 5 | |
The DTM method can also be selected explicitly:
1 | |
Exporting Point Clouds¶
pyforestscan supports exporting processed point clouds to las and laz formats. To export a point cloud as a LAZ file:
1 2 3 | |