skspatial.measurement.area_signed¶
- skspatial.measurement.area_signed(points: Union[ndarray, Sequence]) float [source]¶
Return the signed area of a simple polygon given the 2D coordinates of its veritces.
The signed area is computed using the shoelace algorithm. A positive area is returned for a polygon whose vertices are given by a counter-clockwise sequence of points.
- Parameters:
- pointsarray_like
Input 2D points.
- Returns:
- area_signedfloat
The signed area of the polygon.
- Raises:
- ValueError
If the points are not 2D. If there are fewer than three points.
References
https://en.wikipedia.org/wiki/Shoelace_formula https://alexkritchevsky.com/2018/08/06/oriented-area.html https://rosettacode.org/wiki/Shoelace_formula_for_polygonal_area#Python
Examples
>>> from skspatial.measurement import area_signed
>>> area_signed([[0, 0], [1, 0], [0, 1]]) 0.5
>>> area_signed([[0, 0], [0, 1], [1, 0]]) -0.5
>>> area_signed([[0, 0], [0, 1], [1, 2], [2, 1], [2, 0]]) -3.0