1

I've got two tables, one containing LINESTRINGs and one containing POLYGONEs.

I would like to select all the LINESTRINGs that are containing within the outer boundary of all the POLYGONs combined.

I'm running PostgreSQL 9.3 and PostGIS 2.1.

Is that possible from within the WHERE statement?

1
  • I've tried something like WHERE ST_Contains("geometry", (SELECT geometry FROM POLYGONs)), but that slows the query down very much.
    – Henrik
    Jan 21, 2015 at 13:10

1 Answer 1

3

Sure, using ST_Contains

SELECT lines.*
FROM lines, polygons
WHERE ST_Contains(polygons.geom, lines.geom)
2
  • It worked with ST_Contains(polygons.geom, lines.geom). Thanx.
    – Henrik
    Jan 21, 2015 at 13:13
  • Sorry, I got the order mixed up. Corrected now. Glad you got it working.
    – AndyHarney
    Jan 21, 2015 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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