Io
iter_pc(path, chunk_size=1000000)
Iterates over a LiDAR file in chunks to maintain strict memory safety.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Target .las or .laz file. |
required |
chunk_size
|
int
|
Number of points to stream per chunk. Defaults to 1,000,000. |
1000000
|
Yields:
| Type | Description |
|---|---|
PointCloud
|
Generator[PointCloud, None, None]: Sequential point cloud fragments inheriting global bounding attributes. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the specified file path does not exist on the filesystem. |
Source code in src/phytospatial/lidar/io.py
load_pc(path)
Loads the entirety of a LiDAR point cloud into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Target .las or .laz file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PointCloud |
PointCloud
|
Fully populated object containing coordinates, classifications, and bounds. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the specified file path does not exist on the filesystem. |
Source code in src/phytospatial/lidar/io.py
resolve_pc(func)
A polymorphic, stream-aware decorator that resolves LiDAR point cloud inputs into either instantiated PointCloud objects or memory-safe PointCloud generators.
This function analyzes the target method's signature and runtime arguments. If a target
parameter receives a file path (str or Path), the decorator checks the bound arguments
for the presence of a chunk_size parameter. If chunk_size is populated, it streams
the file via iter_pc(). If omitted, it fully loads the file via load_pc().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
The target function expecting a PointCloud or stream input. |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., Any]
|
Callable[..., Any]: The wrapped function executing with fully resolved dependencies. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a resolved target parameter receives an argument that is not a valid system path, a PointCloud object, or an active Iterator/Generator. |