Package: dendromatics
DendromaticsDescriptionThesrcfolder contains functionalities to detect the trees present in a terrestrial 3D point cloud from a forest plot, and compute individual tree parameters: tree height, tree location, diameters along the stem (including DBH), and stem axis. These are based on an updated version of the algorithm proposed by (Cabo et al., 2018).The functionalities may be divided in four main steps:Height-normalization of the point cloud.Identification of stems among user-provided stripe.Tree individualization based on point-to-stems distances.Robust computation of stems diameter at different section heights.Although individual, somewhat independent functions are provided, they are designed to be used in a script that calls one after the other following the algorithm structure. An example script can be found inexamplefolder.ExamplesHeight-normalizationAlmost all functions in the module expect a height-normalized point cloud to work as intended. If your point cloud is not height-normalized, you can do it in a simple way using some of the module functions. I’ts based on ‘Cloth simulation Filter’ (Zhang et al., 2016).importlaspyimportnumpyasnpimportdendromaticsasdm# Reading the point cloudfilename_las='example_data.las'# your .las fileentr=laspy.read(filename_las)coords=np.vstack((entr.x,entr.y,entr.z)).transpose()# Normalizing the point clouddtm=dm.generate_dtm(clean_points)z0_values=dm.normalize_heights(coords,dtm)# adding the normalized heights to the point cloudcoords=np.append(coords,np.expand_dims(z0_values,axis=1),1)If the point cloud is noisy, you might want to denoise it first before generating the DTM.clean_points=dm.clean_ground(coords)Identifying stems from a stripeSimply provide a stripe (from a height-normalized point cloud) as follows to iteratively ‘peel off’ the stems.# Defining the stripelower_limit=0.5upper_limit=2.5stripe=coords[(coords[:,3]>lower_limit)&(coords[:,3]<upper_limit),0:4]stripe_stems=dm.verticality_clustering(stripe,n_iter=2)Individualizing treesOnce the stems have been identified in the stripe, they can be used to individualize the trees in the point cloud.assigned_cloud,tree_vector,tree_heights=dm.individualize_trees(coords,stripe_stems)Computing sections along the stemscompute_sections() can be used to compute sections along the stems of the individualized trees.# Preprocessing: reducing the point cloud size by keeping only the points that are closer than some radius (expected_R) to the tree axes# and those that are whithin the lowest section (min_h) and the uppest section (max_h) to be computed.expected_R=0.5min_h=0.5max_h=25section_width=0.02xyz0_coords=assigned_cloud[(assigned_cloud[:,5]<expected_R)&(assigned_cloud[:,3]>min_h)&(assigned_cloud[:,3]<max_h+section_width),:]stems=dm.verticality_clustering(xyz0_coords,n_iter=2)[:,0:6]# Computing the sectionssection_len=0.2sections=np.arange(min_h,max_h,section_len)# Range of uniformly spaced values within the specified intervalX_c,Y_c,R,check_circle,second_time,sector_perct,n_points_in=dm.compute_sections(stems,sections)Tilt detectiontilt_detection() computes an ‘outlier probability’ for each section based on its tilting relative to neighbour sections and relative to the tree axis.outlier_prob=dm.tilt_detection(X_c,Y_c,R,sections)For further examples and more thorough explanations, please checkexample.pyscript in/examplesfolder.ReferencesCabo, C., Ordóñez, C., López-Sánchez, C. A., & Armesto, J. (2018). Automatic dendrometry: Tree detection, tree height and diameter estimation using terrestrial laser scanning. International Journal of Applied Earth Observation and Geoinformation, 69, 164–174.https://doi.org/10.1016/j.jag.2018.01.011Prendes, C., Cabo, C., Ordoñez, C., Majada, J., & Canga, E. (2021). An algorithm for the automatic parametrization of wood volume equations from Terrestrial Laser Scanning point clouds: application in Pinus pinaster. GIScience and Remote Sensing, 58(7), 1130–1150.https://doi.org/10.1080/15481603.2021.1972712Zhang, W., Qi, J., Wan, P., Wang, H., Xie, D., Wang, X., & Yan, G. (2016). An easy-to-use airborne LiDAR data filtering method based on cloth simulation. Remote Sensing, 8(6).https://doi.org/10.3390/rs8060501Installdendromaticsis available onPyPIand the full documentation can be consulted onReadTheDocs.iopython -m pip install dendromaticsThe list of dependencies is available in thepyproject.tomlfile.dendromaticsrelies onhatchDepending on your version of Python and your OS, you might also need a C/C++ compiler to compile some of the mandatory dependencies (CSF and jakteristics).
But in any case you would not have to run the compiler by yourself, the build system will manage dependencies and compilation for you.python -m pip install hatchYou can run tests to ensure it works on your computer.hatch run covIt is also possible to build doc locally.hatch run docs:build
hatch run docs:serveand then go tohttp://localhost:8000to browse it.