Skip to main content

Analyzing forest structure using aerial LiDAR data

Project description

PyForestScan: Airborne Point Cloud Analysis for Forest Structure

Binder PyPI Tests Coverage

Calculate Forest Structural Metrics from lidar point clouds in Python

Height Above Ground

Overview

PyForestScan is a Python library designed for analyzing and visualizing forest structure using airborne 3D point cloud data. The library helps derive important forest metrics such as Canopy Height, Plant Area Index (PAI), Canopy Cover, Plant Area Density (PAD), and Foliage Height Diversity (FHD).

Features

  • Forest Metrics: Calculate and visualize key metrics like Canopy Height, PAI, PAD, and FHD.
  • Large Point Cloud Support: Utilizes efficient data formats such as EPT for large point cloud processing.
  • Visualization: Create 2D and 3D visualizations of forest structure and structural metrics
  • Extensibility: Easily add custom filters and visualization techniques to suit your needs.

Installation

Install PyForestScan using pip:

pip install pyforestscan

Dependencies

[!IMPORTANT] You MUST have installed both PDAL and GDAL to use PyForestScan. If you use conda to install PDAL, make sure you install pyforestscan in the conda environment with PDAL (and GDAL if using conda). See https://pdal.io/en/latest/ for more information on PDAL and https://gdal.org/en/stable/.

  • PDAL >= 2.7
  • GDAL >= 3.5
  • Python >= 3.10

Quick Start

Calculate, Export, and Plot Plant Area Index

The following snippet shows how you can load a las file, create 5m by 5m by 1m voxels with points assigned to them, and generate plant area density at 1m layers and plant area index for each 5m grid cell before writing the resulting PAI layer to a geotiff and plotting.

from pyforestscan.handlers import read_lidar, create_geotiff
from pyforestscan.calculate import assign_voxels, calculate_pad, calculate_pai
from pyforestscan.visualize import plot_pai

arrays = read_lidar("example_data/20191210_5QKB020880.laz", "EPSG:32605", hag=True)
voxel_resolution = (5, 5, 1)
voxels, extent = assign_voxels(arrays[0], voxel_resolution)
pad = calculate_pad(voxels, voxel_resolution[-1])
pai = calculate_pai(pad)
create_geotiff(pai, "output_pai.tiff", "EPSG:32605", extent)
plot_pai(pai, extent, cmap='viridis', fig_size=None)

Plant Area Index

Documentation

For detailed instructions and examples, visit our documentation.

Developer Guides

To build locally and contribute to PyForestScan, you will need the following dependencies:

  • PDAL and Python PDAL bindings
  • GDAL
  • Python
  • Python requirements (requirements.txt and requirements-dev.txt)

Testing

PyForestScan uses pytest for running tests. To run the tests, you can follow the steps below:

Running Tests

  1. Install the development dependencies:

    pip install -r requirements-dev.txt
    
  2. Run the tests using pytest:

    pytest
    

This will run all the test cases under the tests/ directory. The tests include functionality checks for filters, forest metrics, and other core components of the PyForestScan library.

You can also run specific tests by passing the test file or function name:

pytest tests/test_calculate.py

Contributing

We welcome contributions! Please check our Contributing Guidelines to get started.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyforestscan-0.2.1.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

pyforestscan-0.2.1-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file pyforestscan-0.2.1.tar.gz.

File metadata

  • Download URL: pyforestscan-0.2.1.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for pyforestscan-0.2.1.tar.gz
Algorithm Hash digest
SHA256 858a7f8e790489e2996a36793c9bcddbcb1a7699e53589ba468fc49a77596019
MD5 bc927f585ab5fc836c109e3fcd3d0434
BLAKE2b-256 3f67f27d1ecf0f33f2dcdf32a72fcf7ca45ac4560017c7350dd650a75d9b795a

See more details on using hashes here.

File details

Details for the file pyforestscan-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyforestscan-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36633508efbc3967eda9cd664ba11b46b16e288a18ee4810e64453fba34d8641
MD5 a1965290d7a12bb6c68a2d37830d2dad
BLAKE2b-256 fea8c7147f61267135ca1a34a44fdce30e4992d466f95509fd335ad18cc8c089

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page