This topic describes the ST_Intersection function. This function returns a geometry object corresponding to the set of points where the input geometry objects intersect.

Syntax

geometry  ST_Intersection(geometry  geomA , geometry  geomB);
geography  ST_Intersection(geography  geogA , geography  geogB);

Parameters

Parameter Description
geomA/geomB The two geometry objects that you want to specify.
geogA/geogB The two geography objects that you want to specify.

Description

  • If the two input geometry objects do not intersect, this function returns an empty geometry object.
  • If you specify geography objects, this function processes the objects by using geometry functions. This function first converts the input geography objects into geometry objects, calculates the intersection of input objects in the planar spatial reference, and then transforms the intersection to a geography object based on the World Geodetic System 1984 (WGS 84) coordinate system.
  • This function does not support GeometryCollection objects.
  • This function deletes the m coordinates of the input objects.

Examples

Results returned by using the default parameter settings:
SELECT ST_AsText(ST_Intersection('POLYGON((0 0,0 2,2 2,2 0,0 0))'::geometry,'POLYGON((0 0,3 0,3 1,0 1,0 0))'::geometry));
           st_astext
--------------------------------
 POLYGON((0 0,0 1,2 1,2 0,0 0))
(1 row)