pchandler.core
The base point cloud class for working with point cloud data.
Classes
Point cloud class with automatic validation and coordinate optimisation. |
- class pchandler.core.PointCloudData
Bases:
CartesianCoordinatesPoint cloud class with automatic validation and coordinate optimisation.
- scalar_fields: ScalarFieldManager
Contains and manages all the scalar fields associated with the point cloud coordinates
- __init__(xyz=None, **kwargs)
Construct a
PointCloudDatafrom XYZ coordinates plus optional per-point scalar fields.- Parameters:
xyz (
Array_Nx3_Float_T) – Input coordinates.**kwargs (Unpack[PointCloudDataKW]) –
Optional keyword arguments — see
PointCloudDataKWfor the full enumeration. Notably:rgb— RGB colour per point.normals— unit normal vectors per point.intensity— intensity scalar field.reflectance— reflectance scalar field.scalar_fields— additional custom scalar fields.socs_origin— scan original coordinate-system origin.Plus every kwarg accepted by
CartesianCoordinates(numerical_optimization_shift,project_transformation,unshifted_bbox,_shift_applied_by).
- property nbPoints: int
Return the number of points in the point cloud.
- Returns:
Point count (number of XYZ rows).
- Return type:
- property normals: NormalFields | None
Return the normal field, if set.
- Returns:
Per-point unit normal vectors, or
Noneif not set.- Return type:
NormalFields | None
- property rgb: RGBFields | None
Return the RGB field, if set.
- Returns:
Per-point RGB colour, or
Noneif not set.- Return type:
RGBFields | None
- property intensity: ScalarField | None
Return the intensity field, if set.
- Returns:
Per-point intensity scalar field, or
Noneif not set.- Return type:
ScalarField | None
- property reflectance: ScalarField | None
Return the reflectance field, if set.
- Returns:
Per-point reflectance scalar field, or
Noneif not set.- Return type:
ScalarField | None
- sample(mask)
Sample a copy of the point cloud restricted to
mask.- Parameters:
mask (IndexLike) – A vector-like index object that corresponds to the number of points in the point cloud.
- Returns:
A new point cloud containing only the masked points (and their scalar fields).
- Return type:
- reduce(mask)
Reduce the point cloud in-place to the subset selected by
mask.- Parameters:
mask (IndexLike) – A vector-like index object that corresponds to the number of points in the point cloud.
- classmethod merge(*pcds, **kwargs)
Merge a set of point clouds together.
If point clouds contain similar scalar fields, these are also merged. Where a scalar field is missing in one point cloud, that field is not retained.
The merge function also manages any optimised shifts required by the new objects.
- Parameters:
*pcds (PointCloudData) – Point clouds to merge in order.
**kwargs (Unpack[PointCloudDataKW]) – Additional keyword arguments forwarded to the base
mergeimplementation — seePointCloudDataKWfor the full enumeration.
- Returns:
A new point cloud whose coordinates and scalar fields are the row-wise concatenation of
pcds.- Return type:
- to_o3d(as_tensor: Literal[False] = False) o3d.geometry.PointCloud
- to_o3d(as_tensor: Literal[True]) o3d.t.geometry.PointCloud
Convert the point cloud to an Open3D
PointCloudobject.- Parameters:
as_tensor (bool) – If
True, build an Open3D tensor-basedPointCloud(o3d.t.geometry).- Returns:
The Open3D point cloud, in legacy or tensor form depending on
as_tensor.- Return type:
- Raises:
ModuleNotFoundError – If
open3dis not installed.
- classmethod from_o3d(pcd_o3d: o3d.geometry.PointCloud) PointCloudData
- classmethod from_o3d(pcd_o3d: o3d.t.geometry.PointCloud) PointCloudData
Convert an Open3D
PointCloudobject to aPointCloudData.- Parameters:
pcd_o3d (
PointCloud|o3d.t.geometry.PointCloud) – Open3D point cloud, either legacy or tensor-based.- Returns:
The converted point cloud (colours/normals are carried over from the legacy Open3D variant; scalar attributes are carried over from the tensor variant).
- Return type:
- Raises:
ModuleNotFoundError – If
open3dis not installed.TypeError – If
pcd_o3dis neither ano3d.geometry.PointCloudnor ano3d.t.geometry.PointCloud.
- to_py4dgeo()
Convert the
PointCloudDatato a py4dgeoEpoch.The optional numerical optimization shift is reverted so py4dgeo receives float64 world-frame coordinates (mirrors
to_o3d()).- Returns:
Epoch carrying
xyzin world-frame, plus optional normals and additional scalar-field dimensions.- Return type:
py4dgeo.Epoch
- Raises:
ModuleNotFoundError – If
py4dgeois not installed.
- classmethod from_py4dgeo(epoch)
Convert a py4dgeo
Epochto aPointCloudData.- Parameters:
epoch (Epoch) – A py4dgeo
Epochto convert.- Returns:
A new point cloud built from the epoch’s cloud, normals, and additional dimensions.
- Return type:
- Raises:
ModuleNotFoundError – If
py4dgeois not installed.