Skip to content
πŸŽ‰ Apache Sedona 1.9.1 is out now! πŸ—ΊοΈ Geography SQL functions, Box2D & Box3D types, raster Python UDFs & more. Read the release notes β†’

ST_IsPolygonCW

Introduction: Returns true if all polygonal components in the input geometry have their exterior rings oriented clockwise and interior rings oriented counter-clockwise. Polygonal components nested inside a GEOMETRYCOLLECTION, at any depth, are recursively inspected. Non-polygonal components (points, line strings, etc.) are ignored.

An input with no polygonal components at all - points, line strings, and empty geometry collections included - vacuously returns true, since there is no ring to violate the requested orientation. This also covers POLYGON EMPTY and MULTIPOLYGON EMPTY. A SQL NULL input returns NULL.

Note

Starting with Sedona 2.0.0, ST_IsPolygonCW matches PostGIS behavior for non-polygonal and GEOMETRYCOLLECTION inputs, and its Flink wrapper's return type changed from a primitive boolean to a nullable Boolean so NULL inputs propagate correctly. Earlier versions returned false for non-polygonal/collection inputs and for NULL. See the release notes for details.

ST_IsPolygonCW

Format: ST_IsPolygonCW(geom: Geometry)

Return type: Boolean

Since: v1.6.0

SQL Example:

SELECT ST_IsPolygonCW(ST_GeomFromWKT('POLYGON ((20 35, 45 20, 30 5, 10 10, 10 30, 20 35), (30 20, 20 25, 20 15, 30 20))'))

Output:

true