5

I have 2 LINESTRING geometries. I know both share a common point. Using PostGIS for Postgres, what is the cleanest way to extract the common point?

Example with illustration:

http://postgis.refractions.net/docs/images/st_touches05.png

How do I extract the intersection of the green and blue line, assuming the points at the crossing are equal?

7

You can use st_intersection

Examples 1:

test=# select st_astext(st_intersection('LINESTRING ( 0 0, 0 2 )'::geometry, 'LINESTRING ( 0 0, 2 0 )'::geometry));

 st_astext  
------------
 POINT(0 0)
(1 fila)

Example 2:

test=# select st_astext(st_intersection('LINESTRING ( 1 0,  0 2 )'::geometry, 'LINESTRING ( 0 0,  2 0 )'::geometry));
 st_astext  
------------
 POINT(1 0)
(1 fila)

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.