I have a polygon geometry and multilinestring geometry. How do i find the intersection of both these geometries. Both the geometries are in same reference system. Does st_intersection gives me the intersection point???


Yes and no. From ST_Intersection:

Returns a geometry that represents the point set intersection of the Geometries.

The result will probably a (Multi)Linestring, where they intersect. To get the points from an intersection of lines and polygons, you need to extract either the exterior ring or interior rings (if they exist) from the polygon. For example, if you just need the exterior ring:

SELECT ST_AsText(ST_Intersection(ST_ExteriorRing(A), B))
  SELECT 'POLYGON ((180 330, 150 270, 225 232, 180 330))'::geometry AS A,
         'LINESTRING (131 315, 270 290, 170 220)'::geometry AS B
) AS data;

Results with

MULTIPOINT(169.075907590759 308.151815181518,191.918860526526 304.043370408898,203.038674033149 243.127071823204,215.791505791506 252.054054054054)

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.