Closed NiklasPhabian closed 7 months ago
It probably doesn't make too much sense to decide if the ring is CCW or CW on the plane. We should test it on the sphere instead.
E.g. chat go:
import numpy as np
def spherical_polygon_orientation(nodes):
total_cross_product = np.cross(nodes[-1], nodes[0])
for i in range(len(nodes) - 1):
total_cross_product += np.cross(nodes[i], nodes[i+1])
if total_cross_product[2] > 0:
return "Counterclockwise"
elif total_cross_product[2] < 0:
return "Clockwise"
else:
return "Undefined (Degenerate Case)"
# Example usage:
vertices = [np.array([x, y, z]) for x, y, z in [(0, 1, 0), (1, 0, 0), (0, 0, 1)]]
orientation = spherical_polygon_orientation(vertices)
print("Orientation:" orientation)
(convert lat/Lon to unit-vectors first)
Should this polygon be considered CCW or CW?
Going by the coordinates, this is of course CW, and shapely's
poly.exterior.is_ccw
will tell us so. But I am wondering if we want the polygon to be understood as CW.STAREPandas currently understands this ring as CW and will invert it. However, pystare seems to interpret this inverted ring as an interior ring.
If we defined the coordinates from 0-360, e.g.
the ring would be CCW