[postgis-users] Postgis overlapping two linestrings

Mike Toews mwtoews at gmail.com
Sun Nov 24 14:00:21 PST 2013


On 23 November 2013 05:50, Ani Alamo <alamo.ani at gmail.com> wrote:
> Uhm... exactly I have this linestrings:
> LINESTRING(2.118932325 41.398745991,2.168720219 41.385631938)
> LINESTRING(2.142346041 41.398526436,2.111181541 41.409216161)
>
> intersections gives me:
> GeometryCollection: GEOMETRYCOLLECTION EMPTY
>
> intersects gives me:
> false
>
> but when I see the line drawn on map I see both lines intersect in a little
> "section" (strectch).

No, these lines don't intersect, they are somewhat parallel to each
other, but not at all even close to touching. You might be confusing
another pair of lines.

> But really when I use intersects or intersection
> functions gives me "unavailable intersection"... and when I use OVERLAPS
> function
> overlaps(buffer(LINESTRING1, 0.001), buffer(LINESTRING2, 0.001)) also gives
> me "false".
>
> Another ideas please??

Avoid using buffer for proximity analysis. Try using ST_DWithin instead:

SELECT
  ST_Distance(A::geography, B::geography) AS dist_m,
  ST_Distance(A::geometry, B::geometry) AS dist,
  ST_DWithin(A::geography, B::geography, 700) AS within_m,
  ST_DWithin(A::geometry, B::geometry, 0.006) AS within
FROM
(SELECT
 'LINESTRING (2.118932325 41.398745991, 2.168720219 41.385631938)'::text AS A,
 'LINESTRING (2.142346041 41.398526436, 2.111181541 41.409216161)'::text as B
) as f;

-[ RECORD 1 ]-----------------
dist_m   | 623.162866494591
dist     | 0.00575141350513493
within_m | t
within   | t


-Mike


More information about the postgis-users mailing list