{"id":49453386,"url":"https://github.com/manaakiwhenua/pycrown","last_synced_at":"2026-05-16T16:01:16.062Z","repository":{"id":44877685,"uuid":"189142565","full_name":"manaakiwhenua/pycrown","owner":"manaakiwhenua","description":"PyCrown - Fast raster-based individual tree segmentation for LiDAR data","archived":true,"fork":false,"pushed_at":"2020-07-21T23:45:39.000Z","size":10062,"stargazers_count":203,"open_issues_count":7,"forks_count":78,"subscribers_count":11,"default_branch":"master","last_synced_at":"2026-01-03T01:49:40.778Z","etag":null,"topics":["crowns","lidar","numba","python","segmentation","tree","trees"],"latest_commit_sha":null,"homepage":"https://datastore.landcareresearch.co.nz/dataset/pycrown","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manaakiwhenua.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-29T03:16:33.000Z","updated_at":"2025-12-09T07:55:05.000Z","dependencies_parsed_at":"2022-08-15T07:30:24.961Z","dependency_job_id":null,"html_url":"https://github.com/manaakiwhenua/pycrown","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/manaakiwhenua/pycrown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manaakiwhenua%2Fpycrown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manaakiwhenua%2Fpycrown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manaakiwhenua%2Fpycrown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manaakiwhenua%2Fpycrown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manaakiwhenua","download_url":"https://codeload.github.com/manaakiwhenua/pycrown/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manaakiwhenua%2Fpycrown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33109461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crowns","lidar","numba","python","segmentation","tree","trees"],"created_at":"2026-04-30T04:01:03.421Z","updated_at":"2026-05-16T16:01:16.056Z","avatar_url":"https://github.com/manaakiwhenua.png","language":"Python","funding_links":[],"categories":["Observation and Conservation of Ecosystems"],"sub_categories":["Vegitation and Biodiversity"],"readme":"[![manaakiwhenua-standards](https://github.com/manaakiwhenua/pycrown/workflows/manaakiwhenua-standards/badge.svg)](https://github.com/manaakiwhenua/manaakiwhenua-standards)\r\n\r\n\r\n# PyCrown - Fast raster-based individual tree segmentation for LiDAR data\r\nAuthor: Dr Jan Schindler (formerly Zörner) (\u003cmailto:schindlerj@landcareresearch.co.nz\u003e)\r\n\r\nPublished under GNU GPLv3\r\n\r\n\r\n# Summary\r\nPyCrown is a Python package for identifying tree top positions in a canopy height model (CHM) and delineating individual tree crowns.\r\n\r\nThe tree top mapping and crown delineation method (optimized with Cython and Numba), uses local maxima in the canopy height model (CHM) as initial tree locations and identifies the correct tree top positions even in steep terrain by combining a raster-based tree crown delineation approach with information from the digital surface model (DSM) and terrain model (DTM).\r\n\r\n*Citation:*\r\n\r\nZörner, J.; Dymond, J.; Shepherd J.; Jolly, B. PyCrown - Fast raster-based individual tree segmentation for LiDAR data. Landcare Research NZ Ltd. 2018, https://doi.org/10.7931/M0SR-DN55\r\n\r\n*Research Article:*\r\n\r\nZörner, J., Dymond, J.R., Shepherd, J.D., Wiser, S.K., Bunting, P., Jolly, B. (2018) Lidar-based regional inventory of tall trees - Wellington, New Zealand. Forests 9, 702-71. https://doi.org/10.3390/f9110702\r\n\r\n\r\n# Purpose and methods\r\nA number of open-source tools to identify tree top locations and delineate tree crowns already exist. The purpose of this package is to provide a fast and flexible Python-based implementation which builds on top of already well-established algorithms.\r\n\r\nTree tops are identified in the first iteration through local maxima in the smoothed CHM.\r\n\r\nWe re-implement the crown delineation algorithms from **Dalponte and Coomes (2016)** in Python. The original code was published as R-package *itcSegment* (\u003chttps://cran.r-project.org/package=itcSegment\u003e) and was further optimized for speed in the *lidR* R-package (\u003chttps://cran.r-project.org/package=lidR\u003e).\r\n\r\nOur Cython and Numba implementations of the original algorithm provide a significant speed-up compared to *itcSegment* and a moderate improvement over the version available in the *lidR* package.\r\n\r\nWe also adapted the crown algorithm slightly to grow in circular fashion around the tree top which gives crown a smoother, more natural looking shape.\r\n\r\nWe add an additional step to correct for erroneous tree top locations on steep slopes by taking either the high point from the surface model or the centre of mass of the tree crown as new tree top.\r\n\r\nReference:\r\n\r\n**Dalponte, M. and Coomes, D.A. (2016)** *Tree-centric mapping of forest carbon density from airborne laser scanning and hyperspectral data*. Methods in Ecology and Evolution, 7, 1236-1245.\r\n\r\n\r\n# Main outputs\r\n* **Tree top locations** (stored as 3D ESRI .shp-file)\r\n* **Tree crowns** (stored as 2D ESRI .shp-file)\r\n* **Individual tree classification of the 3D point cloud** (stored as .las-file)\r\n\r\n\r\n# Contributors\r\n* Dr Jan Zörner (Manaaki Whenua - Landcare Research, Lincoln, New Zealand)\r\n* Dr John Dymond (Manaaki Whenua - Landcare Research, Palmerston North, New Zealand)\r\n* Dr James Shepherd (Manaaki Whenua - Landcare Research, Palmerston North, New Zealand)\r\n* Dr Ben Jolly (Manaaki Whenua - Landcare Research, Palmerston North, New Zealand)\r\n\r\n\r\n# Requirements\r\nIt is assumed that you generated a canopy height model (CHM), digital surface model (DSM) and digital terrain model (DTM) from the LiDAR dataset before running *PyCrown*.\r\nIf you want to classify individual trees in the point cloud, it is recommended to normalize heights to *height above ground elevation* (also done externally).\r\n\r\nFor processing laser scanning data we recommend the open-source software *SPDLib* (http://www.spdlib.org).\r\n\r\n\r\n# Installation and environment set-up\r\n**Python 3.6 is required.**\r\n\r\nTested on: Windows 10, Debian 9 (Stretch), Fedora 28, Ubuntu 18.04 \u0026 16.04\r\n\r\n## Environment set-up\r\n### With Conda package manager (recommended)\r\n#### Create the environment and install all required packages\r\n\r\n`conda env create`\r\n\r\n#### Activate the environment\r\n\r\nWindows: `activate pycrown-env`\r\n\r\nLinux: `source activate pycrown-env`\r\n\r\n### With Python's venv and pip\r\n#### Create the environment\r\n\r\n`python -m venv pycrown-env`\r\n\r\nLinux: `source pycrown-env/bin/activate`\r\n\r\nWindows: `pycrown-env\\Scripts\\activate.bat`\r\n\r\n#### Install all required packages\r\n\r\n`python -m pip install --upgrade pip`\r\n\r\n`pip install -r requirements.txt`\r\n\r\n## Run Tests\r\nThere are only some rudimentary tests provided at the moment, but it is advised to check that everything works:\r\n\r\n`python setup.py test`\r\n\r\n## Install PyCrown\r\nBuild and install the PyCrown module with:\r\n\r\n`python setup.py install`\r\n\r\n\r\n# Common problems\r\n## laspy.util.LaspyException: Laszip was not found on the system\r\nOn some platforms (e.g. Ubuntu 16.04) the installation of laspy does not include laszip/laszip-cli.\r\nSee the [issue report](https://github.com/laspy/laspy/issues/79) on github for more infos.\r\n\r\nIn this case, please follow these steps:\r\n\r\n* `wget http://lastools.org/download/LAStools.zip`\r\n* `unzip LAStools.zip \u0026\u0026 cd LAStools \u0026\u0026 make`\r\n* `cp bin/laszip /home/USERNAME/miniconda3/envs/pycrown-env/bin/`\r\n\r\nIf you encounter this error under Windows, please download LAStools.zip, extract the archive and copy the file \"laszip.exe\" from the \"bin\"-directory to the conda environment, e.g. C:\\Users\\\u003cusername\u003e\\AppData\\Local\\Continuum\\miniconda3\\envs\\pycrown-env\\Scripts\\ or C:\\Users\\\u003cusername\u003e\\Miniconda3\\envs\\pycrown-env\\Scripts\r\n\r\n## Error while building 'pycrown._crown_dalponte_cython' extension\r\nBuilding the Cython module requires C++ build tools which may need to be installed on your system.\r\n\r\nThe Windows error message on Windows provides instructions:\r\n`error: Microsoft Visual C++ 14.0 is required. Get it with \"Build Tools for Visual Studio\": https://visualstudio.microsoft.com/downloads/`\r\nDuring the setup process, please select 'C++ Build Tools'.\r\n\r\n## TypeError: a bytes-like object is required, not 'FakeMmap' when trying to load .laz files\r\nThere seems to be an incompatibility between laspy and numpy in recent versions. The combination `numpy==1.16.4` and `laspy==1.5.1` works for me.\r\nI suggest either not using .laz files for the time being or downgrading to the appropiate package versions.\r\nPlease also refer to this github issue: https://github.com/laspy/laspy/issues/112\r\n\r\n\r\n# Getting Started\r\nYou can find an IPython Notebook demonstrating each step of the tree segmentation approach in the *example* folder.\r\n\r\nYou can also run the example python script directly. Results are stored in the *example/result* folder.\r\n\r\n`cd example`\r\n\r\n`python example.py`\r\n\r\n## Main processing steps\r\n### Step 1: Smoothing of CHM using a median filter\r\n![Step 1](example/step_1.jpg)\r\n\r\n### Step 2: Tree top detection using local maxima filter\r\n![Step 2](example/step_2.jpg)\r\n\r\n### Step 3: Tree Crown Delineation using an adapted Dalponte and Coomes (2016) scheme\r\n![Step 3](example/step_3.jpg)\r\n\r\n### Step 4: Tree top correction of trees on steep slopes\r\n![Step 4](example/step_4.jpg)\r\n\r\n### Step 5: Smoothing of crown polygons using first returns of normalized LiDAR point clouds\r\n![Step 5](example/step_5.jpg)\r\n\r\n### Step 6: Classification of individual trees in the 3D point cloud (visualized with CloudCompare)\r\n![Classified Point Cloud](example/step_6a.jpg)\r\n![Classified Point Cloud](example/step_6b.jpg)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanaakiwhenua%2Fpycrown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanaakiwhenua%2Fpycrown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanaakiwhenua%2Fpycrown/lists"}