0

I have a polygon and a linestring that is part of the polygons boundary, but not necessarily digitized in the same direction as shown here:

enter image description here

In this case the linestring runs in the opposite direction of the polygons boundary.

How can I check if the linestring has the same direction or not using SpatiaLite?

1

A simple solution tested with spatialite would be

ST_Equals(ST_Intersection(theline.geom, thepoly.geom), theline.geom)

ST_Intersection return the portion of the polygons boundary the coincides with the linestring. In spatialite ST_Equals seems to return true if even the point ordering equals, in PostGIS ST_Equals is apparently more lenient, here ST_OrderingEquals must be used instead.

https://postgis.net/docs/ST_Equals.html

https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.