easyidp.pointcloud.geometry

Internal KDTree-based point cloud geometry helpers.

These helpers are importable but not part of the default public API.

KDTree Geometry Helpers

These helpers are internal extension points for point-cloud crop queries. They operate on absolute XY coordinates and return point indices. Ordinary users should call easyidp.pointcloud.PointCloud.crop() or easyidp.ROI.crop() instead.

Function

Purpose

query_indices_by_polygon()

Return point indices inside one polygon.

query_indices_by_multipolygon()

Return point indices inside any polygon of a MultiPolygon.

easyidp.pointcloud.geometry.query_indices_by_polygon(points_xy, polygon_xy, tree=None)

Find indices of points inside a 2D polygon using KDTree pre-filtering.

Uses KDTree bounding-box query (Chebyshev, p=inf) to find candidate points, then applies exact polygon containment via matplotlib Path.

Parameters:
  • points_xy (ndarray of shape (N, 2)) – Absolute XY coordinates of all points.

  • polygon_xy (ndarray of shape (M, 2)) – Polygon boundary vertices in XY plane.

  • tree (cKDTree or None, optional) – Pre-built KDTree over points_xy. If None, builds one.

Returns:

Indices of points inside the polygon.

Return type:

ndarray of int

Examples

>>> points_xy = np.array([[0, 0], [1, 1], [3, 3]])
>>> polygon_xy = np.array([[0, 0], [2, 0], [2, 2], [0, 2]])
>>> query_indices_by_polygon(points_xy, polygon_xy)
array([1])
easyidp.pointcloud.geometry.query_indices_by_multipolygon(points_xy, multipolygon, tree=None)

Query indices for all sub-polygons in a MultiPolygon.

Parameters:
  • points_xy (ndarray of shape (N, 2)) – Absolute XY coordinates of all points.

  • multipolygon (shapely.geometry.MultiPolygon) – The multipolygon to query against.

  • tree (cKDTree or None, optional) – Pre-built KDTree over points_xy.

Returns:

Union of indices inside any sub-polygon, without duplicates.

Return type:

ndarray of int

Examples

>>> from shapely.geometry import MultiPolygon, Polygon
>>> points_xy = np.array([[0, 0], [1, 1], [5, 5]])
>>> geom = MultiPolygon([
...     Polygon([[0, 0], [2, 0], [2, 2], [0, 2]]),
...     Polygon([[4, 4], [6, 4], [6, 6], [4, 6]]),
... ])
>>> query_indices_by_multipolygon(points_xy, geom)
array([1, 2])