A Python library for efficient ray tracing operations on COPC (Cloud Optimized Point Cloud) files.
pymeepcl manages multiple COPC files for efficient spatial queries using ray tracing. It also maintains a cache of loaded point data to speed up subsequent queries. This module makes use of the python bindings of the copc-lib library.
Manages multiple COPC files for efficient ray tracing operations. Provides a unified interface to work with one or more COPC files, enabling efficient spatial queries using ray tracing.
Key Attributes:
cache: Cache for storing loaded node point data to reduce disk readsfiles: List of MeeFile objects representing the loaded COPC filesbounds_copc: Combined global COPC bounding box of all files (tuple of minimums, maximums)bounds_las: Combined global LAS bounding box of all files (tuple of minimums, maximums)
Key Methods:
trace_ray(ray, radius, return_sorted, timer, recursive): Traces a ray through all loaded files and returns points within a cylindrical radiusadd_file(filepath): Adds a new COPC file to the structuredel_file(filepath): Removes a file from the structure and clears associated cache entries
Represents a single COPC file. Handles reading, indexing, and bounding box logic.
Key Attributes:
filepath: The path to the COPC filereader: The reader object for the COPC fileconfig: The configuration object for the COPC filelas_header: The header object for the LAS filenode_entries: List of all nodes in the fileis_indexed: True if the file has been indexed for vectorized intersection testsis_octree_indexed: True if the file has been indexed with octree structurebounds_copc_min,bounds_copc_max: Global COPC bounds of the filebounds_las_min,bounds_las_max: Global LAS bounds of the file
Key Methods:
intersect_global(ray, radius): Checks if ray hits the root boxintersect_nodes(ray, radius): Returns nodes intersected by ray, vectorized intersection testintersect_nodes_octree(ray, radius): Returns nodes intersected by ray, recursively traverses the file, if a parent node isn't hit the children will not be checked
Describes a ray using origin and direction. The direction vector is automatically normalized.
Key Attributes:
origin: Origin point as list or numpy array of shape (3,)direction: Direction vector as list numpy array of shape (3,)
LRU cache for storing loaded node point data to reduce disk reads. Keys are tuples of (filepath, node_key_string), values are copclib.PointData objects.
Key Attributes:
cache: OrderedDict storing the cached node datamax_size: Maximum number of nodes to cache (default: 100)
Container for a clustered point segment and its geometric features, including PCA/eigen features and shape descriptors (linearity, planarity, sphericity, omnivariance).
Key Attributes:
id: Segment identifierpoints: Array of shape (N, 3) containing the point coordinatescentroid: Center of mass (x, y, z)eigenvalues: Array [lambda1, lambda2, lambda3] in descending ordernormal_vector: Eigenvector of smallest eigenvaluelinearity: Shape descriptor (lam1 - lam2) / lam1planarity: Shape descriptor (lam2 - lam3) / lam1sphericity: Shape descriptor lam3 / lam1omnivariance: Shape descriptor (lam1 * lam2 * lam3)^(1/3)
from pymeepcl import MeeStruct, Ray
import numpy as np
# Initialize with a file or directory
struct = MeeStruct("path/to/file.copc.laz")
# or
struct = MeeStruct("path/to/directory/")
# Create a ray
ray = Ray(origin=[0, 0, 0], direction=[0, 0, -1])
# Trace the ray and get points within radius
points = struct.trace_ray(ray, radius=1.0, return_sorted=True)
# Cluster and analyze points
from pymeepcl import cluster_and_analyze
segments = cluster_and_analyze(points, ray, min_points=4)The library can also be used from the command line to trace a single ray and return the points in a specified outputfile:
python pymeepcl.py -i input.copc.laz -p 0 0 0 -d 1 0 0 -r 1 -o output.xyzOptions:
-i, --input: Path to COPC file or directory-p, --projektionszentrum: Origin point (x, y, z)-d, --direction: Direction vector (dx, dy, dz)-r, --radius: Cylinder radius (default: 10m)-o, --output: Output file path (default: punkte.xyz)-R, --recursive: Use recursive octree traversal--no-sorted: Do not sort points by distance along the ray
- Ray tracing with cylindrical radius filtering
- Support for multiple COPC files (tiles)
- Caching mechanism for performance optimization
- Optional recursive octree traversal
- Point clustering and geometric analysis (PCA, shape descriptors)
- Vectorized intersection tests for efficient node checking