Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

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)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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