Apr 19, 2022
Another way to determine winding order of a polygon in BigQuery is to contruct it! If you use ST_MAKEPOLYGONORIENTED, BigQuery assumes the line is oriented and the contents of the polygon is on the left of the line. Then compute it's area. If the actual line followed this rule, you get a normal polygon. If the line winding was opposite - the area of the polygon will be huge (we got inverted polygon). Compare the area with e.g. half of Earth to distinguish these cases.