How to check overlap between two sets of linestrings using PostGIS

We are searching data for your request:
Forums and discussions:
Manuals and reference books:
Data from registers:
Upon completion, a link will appear to access the found materials.
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?
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%