I have two sets of LINESTRINGS, each set containing around 50 LINESTRINGS (which form a road), using PostGIS how do I check whether these two sets overlap or not?
-
1boolean ST_Overlaps(geometry A, geometry B); see postgis.org/docs/ST_Overlaps.html– simpleuser001Sep 16, 2015 at 11:54
1 Answer
As simplexio pointed out, the ST_Overlaps function is an excellent start; however, you should check out this post that explains some of the nuances and varying behaviours between ST_Overlaps and ST_Intersects - specifically when two geometries are identical.
Here is a query that I use to detect overlaps in a road network - two line geometries that share a line segment. You can remove the t1.id <> t2.id test if you are testing overlaps between two different tables.
SELECT t1.id
FROM t1, t2
WHERE t1.id <> t2.id
AND ST_Intersects(t1.geom, t2.geom)
AND Upper(ST_GeometryType(ST_Intersection(t1.geom, t2.geom))) LIKE '%LINE%