Operation functions can be used to manage values of the GEOMETRY data type.

  • ST_Intersection: returns a geometry that represents the intersection of g1 and g2.
  • ST_Envelope: takes data of the LINE, POLYGON, MULTILINE, and MULTIPOLYGON GEOMETRY types as an input. This function does not support the POINT GEOMETRY data type. This function returns a binary representation of an envelope, in which an envelope refers to the rectangle that encloses the specified geometry.
  • ST_Union: returns a geometry that represents the point set union of the specified geometries.
  • geometry_union: returns a geometry that represents the point set union of the specified geometries.
  • ST_Boundary: takes one of the GEOMETRY data types as an input and returns a binary representation of the BOUNDARY GEOMETRY data type.
  • ST_EnvelopeAsPts: returns an array of two points that represent the lower-left and upper-right corners of the bounding rectangular polygon of a geometry. null is returned if the specified geometry is empty.
  • ST_Difference: returns a geometry that represents the difference between the left geometry and the right geometry.
  • ST_ExteriorRing: returns the exterior ring of a polygon as a linestring.
  • ST_SymDifference: returns a geometry that represents the symmetric difference between the left geometry and the right geometry.

ST_Intersection

ST_Intersection(g1, g2)
  • Description: This function returns a geometry that represents the intersection of g1 and g2.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_Intersection(ST_GeometryFromText('MULTIPOINT (50 100, 50 200)'), ST_GeometryFromText('Point (50 100)'));
    +------------------------------------------------------------------------------------------------------------+
    | ST_Intersection(ST_GeometryFromText('MULTIPOINT (50 100, 50 200)'), ST_GeometryFromText('Point (50 100)')) |
    +------------------------------------------------------------------------------------------------------------+
    |                         �?      �?                                                                         |
    SELECT ST_AsText(ST_Intersection(ST_GeometryFromText('MULTIPOINT (50 100, 50 200)'), ST_GeometryFromText('Point (50 100)')));
    +-----------------------------------------------------------------------------------------------------------------------+
    | ST_AsText(ST_Intersection(ST_GeometryFromText('MULTIPOINT (50 100, 50 200)'), ST_GeometryFromText('Point (50 100)'))) |
    +-----------------------------------------------------------------------------------------------------------------------+
    |                        POINT (50 100)                                                                                 |

ST_Envelope

ST_Envelope(g)
  • Description: This function takes data of the LINE, POLYGON, MULTILINE, and MULTIPOLYGON GEOMETRY types as an input. This function does not support the POINT GEOMETRY data type. This function returns a binary representation of an envelope, in which an envelope refers to the rectangle that encloses the specified geometry.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_Envelope(ST_GeometryFromText('LINESTRING (1 1, 2 2, 1 3)')))  +
    *---------------------------------------------------------------------------------+
    |ST_AsText(ST_Envelope(ST_GeometryFromText('LINESTRING (1 1, 2 2, 1 3)')))        |
    +---------------------------------------------------------------------------------+   
    |                POLYGON ((1 1, 2 1, 2 3, 1 3, 1 1))                                   | 
    SELECT ST_AsText(ST_Envelope(ST_GeometryFromText('MULTIPOINT (1 2, 2 4, 3 6, 4 8)')));
    +-------------------------------------------------------------------------------+
    | ST_AsText(ST_Envelope(ST_GeometryFromText('MULTIPOINT (1 2, 2 4, 3 6, 4 8)')))|
    +-------------------------------------------------------------------------------+
    |                        POLYGON ((1 2, 4 2, 4 8, 1 8, 1 2))                    | 

ST_Union

ST_Union(g1, g2)
  • Description: This function returns a geometry that represents the point set union of the specified geometries.
  • Return value type: INT.
  • Example:
    SELECT ST_ASText(ST_Union(ST_GeometryFromText('MULTIPOLYGON (((1 1, 3 1, 3 3, 1 3, 1 1)))'), ST_GeometryFromText('MULTIPOLYGON (((2 2, 4 2, 4 4, 2 4, 2 2)))')));
    +----------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | ST_ASText(ST_Union(ST_GeometryFromText('MULTIPOLYGON (((1 1, 3 1, 3 3, 1 3, 1 1)))'), ST_GeometryFromText('MULTIPOLYGON (((2 2, 4 2, 4 4, 2 4, 2 2)))')))      |
    +----------------------------------------------------------------------------------------------------------------------------------------------------------------+   
    |                                    POLYGON ((1 1, 3 1, 3 2, 4 2, 4 4, 2 4, 2 3, 1 3, 1 1))                                                                     | 

geometry_union

geometry_union(array[g1, g2, ...])
  • Description: This function returns a geometry that represents the point set union of the specified geometries.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT geometry_union(ARRAY[ST_Point(61.56, -158.54), ST_Point(61.56, -158.55)]);
    +---------------------------------------------------------------------------------+
    |  geometry_union(ARRAY[ST_Point(61.56, -158.54), ST_Point(61.56, -158.55)])      |
    +---------------------------------------------------------------------------------+   
    |                   �?      �?                                                    | 

ST_Boundary

ST_Boundary(g)
  • Description: This function takes one of the GEOMETRY data types as an input and returns a binary representation of the BOUNDARY GEOMETRY data type.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_Boundary(ST_GeometryFromText('LINESTRING (8 4, 5 7)')))  +
    *----------------------------------------------------------------------------+
    |ST_AsText(ST_Boundary(ST_GeometryFromText('LINESTRING (8 4, 5 7)')))        |
    +----------------------------------------------------------------------------+   
    |                MULTIPOINT ((8 4), (5 7))                                   | 

ST_EnvelopeAsPts

ST_EnvelopeAsPts(g)
  • Description: This function returns an array of two points that represent the lower-left and upper-right corners of the bounding rectangular polygon of a geometry. null is returned if the specified geometry is empty.
  • Return value type: Array[Geometry].
  • Example:
    SELECT ST_EnvelopeAsPts(ST_GeometryFromText('LINESTRING EMPTY'))  +
    *-----------------------------------------------------------------+
    |ST_EnvelopeAsPts(ST_GeometryFromText('LINESTRING EMPTY'))        |
    +-----------------------------------------------------------------+   
    |                null                                             | 

ST_Difference

ST_EnvelopeAsPts(g1, g2)
  • Description: This function returns a geometry that represents the difference between the left geometry and the right geometry.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_Difference(ST_GeometryFromText('POINT (50 100)'), ST_GeometryFromText('POINT (150 150)')))  +
    *---------------------------------------------------------------------------------------------------------------+
    |ST_AsText(ST_Difference(ST_GeometryFromText('POINT (50 100)'), ST_GeometryFromText('POINT (150 150)')))        |
    +---------------------------------------------------------------------------------------------------------------+   
    |                POINT (50 100)                                                                                 | 

ST_ExteriorRing

ST_ExteriorRing(g1)
  • Description: This function returns the exterior ring of a polygon as a linestring.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_ExteriorRing(ST_GeometryFromText('POLYGON ((1 1, 1 4, 4 1))')))  +
    *------------------------------------------------------------------------------------+
    |ST_AsText(ST_ExteriorRing(ST_GeometryFromText('POLYGON ((1 1, 1 4, 4 1))')))        |
    +------------------------------------------------------------------------------------+   
    |                LINESTRING (1 1, 4 1, 1 4, 1 1)                                     | 

ST_SymDifference

ST_SymDifference(g1, g2)
  • Description: This function returns a geometry that represents the symmetric difference between the left geometry and the right geometry.
  • Return value type: GEOMETRY. If you execute the SELECT statement to query results of this function, the returned results are corrupted.
  • Example:
    SELECT ST_AsText(ST_SymDifference(ST_GeometryFromText('POINT (50 100)'), ST_GeometryFromText('POINT (50 150)')))  +
    *-----------------------------------------------------------------------------------------------------------------+
    |ST_AsText(ST_SymDifference(ST_GeometryFromText('POINT (50 100)'), ST_GeometryFromText('POINT (50 150)')))        |
    +-----------------------------------------------------------------------------------------------------------------+   
    |                MULTIPOINT ((50 100), (50 150))                                                                  |