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 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???

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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))
FROM (
  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)
share|improve this answer

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.