I have two tables in my PostgreSQL 9.5 database i.e., roads and polygons. The sample scenarios are as:





In PostGIS, for each road how can I detect whether polygons are one side of the road center line or on both sides?

  • 3
    You could use st_offsetcurve to create left side and right side offset lines, then use these and the original line to turn into polygons right and left, then test if the input polygon touches the right or left side polygon. – jbalk Jun 12 '17 at 6:50
  • Thank you for your suggestion. ST_OffsetCurve() only works with linestring I think. So, maybe this process cant be automated for large datasets (multilinestrings). – khajlk Jun 12 '17 at 7:38
  • It can, you just need to convert to linestring first. st_dump works for this. – jbalk Jun 13 '17 at 1:21

There is a new single-sided buffer option in Postgis. However, this is currently only available in trunk so you will either have to build from source or download a nightly / experimental build. It should be generally available as of the 2.5 release when that appears. See this man page.

| improve this answer | |

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.