Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to check or correct the "orient" of polygons #71

Closed
jorisvandenbossche opened this issue Oct 30, 2019 · 6 comments
Closed

Function to check or correct the "orient" of polygons #71

jorisvandenbossche opened this issue Oct 30, 2019 · 6 comments
Labels
enhancement New feature or request to-GEOS This issue needs to be solved upstream (in GEOS)

Comments

@jorisvandenbossche
Copy link
Member

Shapely has a orient function to make a copy of a Polygon with "proper" orientation of the rings: https://shapely.readthedocs.io/en/latest/manual.html#shapely.geometry.polygon.orient (definition in the code: https://github.com/Toblerity/Shapely/blob/b21a964a56a86cf77c67b477db7e7c2e81d2ccb5/shapely/geometry/polygon.py#L391-L404)

In addition, Shapely also has a is_ccw (is counter clock wise) attribute on LinearRings: https://shapely.readthedocs.io/en/latest/manual.html#object.is_ccw

For this, there is a GEOS C API function: https://github.com/libgeos/geos/blob/eb4da1440836fedf503e1eb2c245595a0f33db5e/capi/geos_c.h.in#L351-L357 (although Shapely implements it manually by calculating the signed area)

@jorisvandenbossche
Copy link
Member Author

Postgis also has a set of methods related to this: ST_ForcePolygonCCW, ST_ForcePolygonCW , ST_IsPolygonCCW , ST_IsPolygonCW (see eg https://postgis.net/docs/ST_ForcePolygonCCW.html)

@jorisvandenbossche
Copy link
Member Author

Possible related to this is also GEOSNormalize_r (https://postgis.net/docs/ST_Normalize.html)

@caspervdw
Copy link
Member

#126 --> implement is_ccw

@jorisvandenbossche
Copy link
Member Author

It's potentially a bit more than just is_ccw, eg both Shapely and Postgis also have functions to convert to consistent orientation, in addition to checking the orientation.

@caspervdw
Copy link
Member

Ok sorry I was a bit fast closing this then. Let’s investigate!

@jorisvandenbossche
Copy link
Member Author

I opened an equivalent function in Shapely: shapely/shapely#1366, so let's close here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request to-GEOS This issue needs to be solved upstream (in GEOS)
Projects
None yet
Development

No branches or pull requests

2 participants