pysnt.converters.tree_converters module#
Tree conversion utilities for PySNT.
This module provides functions to convert SNT Tree objects into Python data structures.
- tree_to_points(tree)[source]#
Extract node coordinates from a Tree as a numpy array.
This is a convenience function that extracts the numpy array directly. Tree objects are also automatically converted when using pysnt.to_python(), which returns the same numpy array.
- Parameters:
tree (Tree) – PySNT Tree object
- Returns:
Array of shape (N, 3) containing XYZ coordinates
- Return type:
np.ndarray
Examples
>>> from pysnt.converters.tree_converters import tree_to_points >>> points = tree_to_points(tree) >>> print(points.shape) # (N, 3)
>>> # Automatic conversion via pysnt.to_python() returns the same array: >>> points = pysnt.to_python(tree) # Same numpy array result >>> print(points.shape) # (N, 3)
Notes
The difference between this function and pysnt.to_python(tree): - tree_to_points(tree): Returns numpy array directly - pysnt.to_python(tree): Also returns numpy array (via registered converter) - _convert_tree_to_points(tree): Returns SNTObject dict (internal use only)