# Given 2 LINESTRINGs with common point, how to extract common point?

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:

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

-

## 1 Answer

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)

-