skspatial.objects.Points

class skspatial.objects.Points(array: Union[numpy.ndarray, Sequence])[source]

Multiple points in space implemented as a 2D array.

The array is a subclass of numpy.ndarray. Each row in the array represents a point in space.

Parameters
pointsarray_like

(N, D) array representing N points with dimension D.

Raises
ValueError

If the array is empty, the values are not finite, or the dimension is not two.

Examples

>>> from skspatial.objects import Points
>>> points = Points([[1, 2, 0], [5, 4, 3]])
>>> points
Points([[1, 2, 0],
        [5, 4, 3]])
>>> points.dimension
3

The object inherits methods from numpy.ndarray.

>>> points.mean(axis=0)
array([3. , 3. , 1.5])
>>> Points([])
Traceback (most recent call last):
...
ValueError: The array must not be empty.
>>> import numpy as np
>>> Points([[1, 2], [1, np.nan]])
Traceback (most recent call last):
...
ValueError: The values must all be finite.
>>> Points([1, 2, 3])
Traceback (most recent call last):
...
ValueError: The array must be 2D.

Methods

affine_rank(**kwargs)

Return the affine rank of the points.

are_collinear(**kwargs)

Check if the points are all contained in one line.

are_concurrent(**kwargs)

Check if the points are all contained in one point.

are_coplanar(**kwargs)

Check if the points are all contained in one plane.

centroid()

Return the centroid of the points.

is_close(other, **kwargs)

Check if the array is close to another.

mean_center([return_centroid])

Mean-center the points by subtracting the centroid.

plot_2d(ax_2d, **kwargs)

Plot the points on a 2D scatter plot.

plot_3d(ax_3d, **kwargs)

Plot the points on a 3D scatter plot.

unique()

Return unique points.