pytreedb
A Python software package providing an object-based library to provide a simple database interface and REST API of vegetation tree objects that were captured as 3D point clouds.
https://github.com/3dgeo-heidelberg/pytreedb
Category: Biosphere
Sub Category: Forest Remote Sensing
Last synced: about 7 hours ago
JSON representation
Repository metadata
Python package providing a file and object-based database to store tree objects.
- Host: GitHub
- URL: https://github.com/3dgeo-heidelberg/pytreedb
- Owner: 3dgeo-heidelberg
- License: other
- Created: 2022-03-17T12:33:55.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T09:09:45.000Z (3 months ago)
- Last Synced: 2025-06-26T00:13:02.824Z (2 days ago)
- Language: Python
- Size: 65.9 MB
- Stars: 40
- Watchers: 3
- Forks: 4
- Open Issues: 5
- Releases: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: COPYING
- Citation: CITATION.cff
README.md
pytreedb
is a Python
software package providing an object-based library to provide a simple database interface and REST API of vegetation tree objects that were captured as 3D point clouds. The main objective is to provide a Python library for the storage and sharing of single tree-based point clouds and all relevant (forest inventory) tree measurements. The tree data include all tree related information, measurements, metadata, geoinformation and also links to the 3D point clouds linked in any file format (e.g. LAS/LAZ). GeoJSON
including all tree-related information is used as data format for data exchange and visualization with other software (e.g. direct import into most GIS). Thereby view and modification of the tree datasets (*.geojson) is straightforward.
MongoDB is used as database backend via the PyMongo driver. This enables scaling to large global datasets, e.g. connecting to MongoDB Atlas Cloud for big datasets. Working only locally using a local MongoDB installation is also possible, if the database is only needed during runtime of data processing and sharing on the Web is not required.
Main Features
pytreedb
has three main components and usage directions:
- Python library: In case you need to access the tree database in your Python scripts during runtime of data processing and analysis.
- REST API: In case you want to provide your datasets to any software over a REST API. The
pytreedb
server application is using the Flask framework for local(host) usage and we provide instructions to setup for production deployment with Apache WGSI. Further info on the REST API ofpytreedb
can be found here, e.g. including setup of server and usage of API keys. - Web frontend: In case you want to share your valuable tree data to the community. Based on the REST API we showcase in this repository how a Web frontend can be easily implemented, which provides several query options, data export and also map views of query results. A showcase presenting the tree data of Weiser et al. 2022 and further datasets is given on http://pytreedb.geog.uni-heidelberg.de/.
The PyTreeDB
class is the starting point and the core component. It is responsible, e.g., for
- data import, data export, data validation, automatic sync with MongoDB
- all kind of queries.
The Python
REST interface and all clients, such as the web frontend, simply use the methods and functionality of the Python class.
The main concept of the pytreedb
software was explained in a scientific talk by Bernhard Höfle at the 3DForEcoTech Workshop in Prague in 2022:
💻 Download and Installation
Installation
Install and update using pip for 1) core library and 2) server library using the core library:
1) Core library
$ pip install -U pytreedb
2) Server library
$ pip install -U pytreedb-server
Alternative Installation
Clone this Repo and Use Anaconda Environment
Clone this repository with git clone
and use it as your working directory.
Simply use the given Anaconda
environment file environment.yml provided in this distribution, which contains all dependencies to run and build resources.
$ conda env create --file environment.yml --force
Instead, you can also install the dependencies from the requirements file with pip.
$ python -m pip install -r requirements.txt
or the entire package:
$ python -m pip install .
Finally, if you want to contribute to the library's development you should also install its additional Python dependencies for testing and documentation building:
$ python -m pip install -r requirements-dev.txt
Connect to MongoDB (localhost / server / Atlas cloud)
pytreedb
requires a working connection to a MongoDB
database. It does not matter where the MongoDB is running as connection is simply made via pymongo
(see code in examples and our Jupyter notebooks). We successfully tested localhost, server and MongoDB Atlas cloud connections. For your own MongoDB installation, just follow the official installation instructions).
The required MongoDB connection with credentials is made with a .env
file (yes, the file has no name) that you place in the folder of your Python scripts or search path. dotenv is used for providing credentials - 1) URI to server, 2) database and 3) collection name - outside your source code (see sample.env as template).
Example .env
file for connection to local MongoDB installation. ℹ️ Replace <database_name> and <collection_name> with your settings:
CONN_URI = "mongodb://127.0.0.1:27017/"
CONN_DB = "<database_name>"
CONN_COL = "<collection_name>"
Example CONN_URI in .env
file for connection to MongoDB Atlas cloud where the respective settings need to be replaced with yours:
CONN_URI = "mongodb+srv://<username>:<password>@<your_cluster_details>.mongodb.net/<database_name>?retryWrites=true&w=majority"
Software Dependencies
All dependencies (i.e. required third-party Python packages) are listed in the Anaconda environment.yml definition and can be installed with conda / pip. When creating the conda environment from our definition file, all dependencies are resolved.
Documentation of Software Usage
PyTreeDB
class 🐍
As a starting point, please have a look to the examples and Jupyter Notebooks available in the repository. Further, each of the subfolders contains a README.md with respective details on the repository section.
Run it as a API server 💻
In order to provide a REST API to share your tree data you can use pytreedb
in server mode. After installation of the pytreedb-server
Python package you can follow the instructions here webserver/README.md.
Run it as a web server and frontend
An example web frontend instance is running here: http://pytreedb.geog.uni-heidelberg.de/. The respective instructions and codes to install a webpage via the pytreedb-server
Python package can be found in the webserver code section of pytreedb
: pytreedb/webserver. Web frontend codes can be easily adapted to your needs - see web programming codes in static and templates.
Use it as via the REST API also from other programming languages (e.g. R stats)
Straightforward access from any programming language is made possible via the REST API. We provide examples scripts for http API access, e.g. for R statistics in examples_api. The R function example allows simple query and also download of the LAZ files for all trees of the query result.
GeoJSON Format and Template
An example tree is given in data/geojson/AbiAlb_BR03_01.geojson and the GeoJSON template for tree objects is defined here pytreedb/db_conf.py.
The single tree information (incl. URLs to the point clouds) has to be provided as GeoJSON
file per tree. We use a straightforward format that is a valid GeoJSON and can be opened with any GIS software. The main idea of the pytreedb GeoJSON format is to define a minimum set of tree metadata, which can be extended by any further data that is needed by the user. Thus, it is just required that your GeoJSON file complies with the minimum set to enable import into the database. The PyTreeDB
class offers the method validate_json
to check the validity of the file. Also the import of files checks the validity automatically and will only import tree objects that are conformal with the defined template. The used GeoJSON template can also be modified for your use case and application. Note that modification (e.g. removal of mandatory fields from our template) will - most probably - require modifications for the API and web frontend component.
Published Test Data
The test data is provided in data
as 1) single GeoJSON files and as ZIP archive, and 2) also as serialized and zipped pytreedb database dump files that can be directly imported and used to start the API server.
1) SYSSIFOSS-Data
We provide metadata (incl. links to point clouds) of 1481 trees that have been captured with airborne (ALS), UAV-borne (ULS) and terrestrial (TLS) laser scanning as well as field inventory data. This data was acquired and processed as part of the DFG project syssifoss and the trees are located in the forests of Bretten and Karlsruhe (Germany). Please check our data publication for full details:
Weiser, H., Schäfer, J., Winiwarter, L., Krašovec, N., Fassnacht, F.E. & Höfle, B. (2022): Individual tree point clouds and tree measurements from multi-platform laser scanning in German forests. Earth System Science Data. Vol. 14 (7), pp. 2989-3012. https://doi.org/10.5194/essd-14-2989-2022
The data can be downloaded from PANGAEA: https://doi.org/10.1594/PANGAEA.942856
For 11 trees, this dataset was extended by labelled versions of the TLS point clouds which have pointwise annotations for the semantic classes leaf and wood. The point clouds can be filtered using the "Labels" filter and are also available from heiDATA.
Weiser, H., Ulrich, V., Winiwarter, L., Esmorís, A, M. & Höfle, B. (2024): Manually labeled terrestrial laser scanning point clouds of individual trees for leaf-wood separation. heiDATA, V1, https://doi.org/10.11588/DATA/UUMEDI.
2) Landmark trees in Heidelberg, Germany
Over time, we additionally added two landmark trees scanned in Heidelberg, Germany:
- Holdermannseiche (Quercus robur), Heiligenberg
- Giant sequoia (Sequoiadendron giganteum), Arboretum 1
Quick tutorial:
3) LiPheStream catalogue
LiPheStream is the first external dataset that we added to pytreedb
. LiPheStream is a time series tree dataset from a permanent laser scanning (PLS) system in Finland.
Wittke, S., Campos, M., Ruoppa, L., Echrit, R., Wang, Y., Gołoś, A., Kukko, A., Hyyppä, J. & Puttonen, E. (2024): LiPheStream - A 18-month high spatiotemporal resolution point cloud time series of Boreal trees from Finland. Scientific Data, Vol. 11, 1281. https://doi.org/10.1038/s41597-024-04143-w.
The entire LiPheStream dataset is available from the Finnish Fairdata service: https://doi.org/10.23729/cf81f7f3-faaa-4729-aa1c-aa4dd38951aa
Citation
Please cite the following publication when using pytreedb in your research and reference the appropriate release version. All releases of pytreedb are listed on Zenodo where you will find the citation information including DOI.
Höfle, B., Qu, J., Winiwarter, L., Weiser, H., Zahs, V., Schäfer, J. & Fassnacht, F. E. (2023). pytreedb - library for point clouds of tree vegetation objects (1.0.0). Zenodo. https://doi.org/10.5281/zenodo.7551310
@software{hofle_bernhard_2023_7551310,
author = {Höfle, Bernhard and
Qu, Jiani and
Winiwarter, Lukas and
Weiser, Hannah and
Zahs, Vivien and
Schäfer, Jannika and
Fassnacht, Fabian E.},
title = {{pytreedb - library for point clouds of tree
vegetation objects}},
month = jan,
year = 2023,
publisher = {Zenodo},
version = {1.0.0},
doi = {10.5281/zenodo.7551310},
url = {https://doi.org/10.5281/zenodo.7551310}
}
Funding / Acknowledgements
The initial software development was supported by the DFG - German Research Foundation (Grant no. 411263134) within the research project SYSSIFOSS.
Contact / Bugs / Feature Requests
You think you have found a bug or have specific request for a new feature. Please open a new issue in the online code repository on Github. Also for general questions please use the issue system.
Scientific requests can be directed to the 3DGeo Research Group Heidelberg and its respective members.
📜 License
See LICENSE.md
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: Höfle given-names: Bernhard orcid: "https://orcid.org/0000-0001-5849-1461" - family-names: Qu given-names: Jiani - family-names: Winiwarter given-names: Lukas orcid: "https://orcid.org/0000-0001-8229-1160" - family-names: Weiser given-names: Hannah orcid: "https://orcid.org/0000-0003-3256-7311" - family-names: Zahs given-names: Vivien orcid: "https://orcid.org/0000-0001-8200-1661" - family-names: Schäfer given-names: Jannika - family-names: Fassnacht given-names: Fabian E. orcid: "https://orcid.org/0000-0003-1284-9573" title: pytreedb - library for point clouds of tree vegetation objects. version: 1.0.0 date-released: 2023-01-19 identifiers: - description: This is the collection of archived snapshots of all versions of pytreedb type: doi value: "10.5281/zenodo.7551310" license: ["GPL-3.0-or-later", "LGPL-3.0-or-later"] repository-code: "https://github.com/3dgeo-heidelberg/pytreedb"
Owner metadata
- Name: 3DGeo Research Group, Heidelberg University
- Login: 3dgeo-heidelberg
- Email:
- Kind: organization
- Description: The 3DGeo Research Group investigates and develops computational methods for the geographic analysis of 3D/4D point clouds.
- Website: https://uni-heidelberg.de/3dgeo
- Location: Heidelberg, DE
- Twitter: 3DGeoHD
- Company:
- Icon url: https://avatars.githubusercontent.com/u/75726016?v=4
- Repositories: 6
- Last ynced at: 2023-03-03T19:43:15.552Z
- Profile URL: https://github.com/3dgeo-heidelberg
GitHub Events
Total
- Issues event: 9
- Watch event: 7
- Delete event: 7
- Issue comment event: 3
- Member event: 2
- Push event: 34
- Pull request event: 12
- Create event: 7
Last Year
- Issues event: 9
- Watch event: 7
- Delete event: 7
- Issue comment event: 3
- Member event: 2
- Push event: 34
- Pull request event: 12
- Create event: 7
Committers metadata
Last synced: 2 days ago
Total Commits: 623
Total Committers: 14
Avg Commits per committer: 44.5
Development Distribution Score (DDS): 0.624
Commits in past year: 9
Committers in past year: 2
Avg Commits per committer in past year: 4.5
Development Distribution Score (DDS) in past year: 0.222
Name | Commits | |
---|---|---|
han16nah | h****h@m****g | 234 |
[Jiani | j****u@u****e | 222 |
Bernhard Höfle | h****e@u****e | 67 |
Lukas Winiwarter | l****r@u****e | 31 |
bhoefle-3dgeo | b****e@n****e | 24 |
Lukas Winiwarter | l****r@g****t | 17 |
Hannah Weiser | h****r@s****e | 10 |
annachiu7 | q****9@g****m | 6 |
ep413 | z****s@u****e | 4 |
Lukas Winiwarter | l****r@s****e | 3 |
momueller2 | 8****2 | 2 |
geogem | l****r@g****t | 1 |
Bernhard Höfle | b****e@s****e | 1 |
Lukas Winiwarter | w****r@u****e | 1 |
Committer domains:
- uni-heidelberg.de: 5
- syssifoss.geog.uni-heidelberg.de: 2
- gmx.at: 2
- stud.uni-heidelberg.de: 1
- nb-5786.geog.uni-heidelberg.de: 1
- mailbox.org: 1
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 114
Total pull requests: 129
Average time to close issues: 26 days
Average time to close pull requests: 3 days
Total issue authors: 8
Total pull request authors: 5
Average comments per issue: 1.59
Average comments per pull request: 0.38
Merged pull request: 126
Bot issues: 0
Bot pull requests: 0
Past year issues: 9
Past year pull requests: 13
Past year average time to close issues: 25 days
Past year average time to close pull requests: about 24 hours
Past year issue authors: 1
Past year pull request authors: 2
Past year average comments per issue: 0.22
Past year average comments per pull request: 0.0
Past year merged pull request: 13
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- bhoefle-3dgeo (36)
- han16nah (28)
- annachiu7 (22)
- JannikaSchaefer (11)
- lwiniwar (9)
- wiesehahn (4)
- ArashJavan (3)
- vivienzahs (1)
Top Pull Request Authors
- han16nah (96)
- annachiu7 (20)
- lwiniwar (8)
- momueller2 (4)
- bhoefle-3dgeo (1)
Top Issue Labels
- enhancement (5)
- release (3)
- bug (1)
Top Pull Request Labels
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 13 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
pypi.org: pytreedb
python library for tree database management and access
- Homepage:
- Documentation: https://pytreedb.readthedocs.io/
- Licenses: (L)GPL License
- Latest release: 1.0.0 (published over 2 years ago)
- Last Synced: 2025-06-27T00:30:55.216Z (1 day ago)
- Versions: 3
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 13 Last month
-
Rankings:
- Dependent packages count: 6.633%
- Downloads: 13.628%
- Average: 16.957%
- Dependent repos count: 30.611%
- Maintainers (1)
Dependencies
- myst-parser ==0.18.1
- sphinx >=4.3.0
- sphinx-rtd-theme >=0.5.1
- actions/checkout v3 composite
- actions/setup-python v3 composite
- supercharge/mongodb-github-action 1.7.0 composite
- actions/checkout v3 composite
- actions/download-artifact v2 composite
- actions/setup-python v2 composite
- actions/upload-artifact v2 composite
- pypa/gh-action-pypi-publish master composite
- supercharge/mongodb-github-action 1.7.0 composite
- flask ==2.1.2
- notebook ==6.4.12
- numpy ==1.23.0
- pymongo ==4.1.1
- python-dotenv ==0.20.0
- flake8 * development
- flake8_nb * development
- myst-parser * development
- pre-commit * development
- pytest * development
- requests * development
- sphinx * development
- sphinxcontrib-napoleon * development
- flask ==2.1.2
- folium ==0.12.1.post1
- laspy ==2.1.2
- matplotlib ==3.5.2
- notebook ==6.4.12
- numpy ==1.23.0
- pymongo ==4.1.1
- python-dotenv ==0.20.0
- shapely ==1.8.2
- black *
- black_nbconvert *
- flake8 *
- flake8-nb *
- pymongo *
Score: 9.084777149000836