ST_RemovePoint function

The ST_RemovePoint function takes a curve and a point as input parameters and returns the specified curve with all points equal to the specified point removed from it. If the specified curve has Z or M coordinates, then the point must also have Z or M coordinates. The resulting geometry is represented in the spatial reference system of the specified geometry.

If the specified curve is empty, then an empty curve is returned. If the specified curve is null, or if the specified point is null or empty, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramST_RemovePoint(curve,point )

Parameters

curve
A value of type ST_Curve or one of its subtypes that represents the curve from which point is removed.
point
A value of type ST_Point that identifies the points that are removed from curve.

Return type

ST_Curve

Examples

Example 1
In the following example, two linestrings are added to the SAMPLE_LINES table. These linestrings are used in the following examples.

CREATE TABLE sample_lines (id INTEGER, line ST_LineString)

INSERT INTO sample_lines
  VALUES (1,ST_LineString('linestring 
         (10 10, 5 5, 0 0, 10 0, 5 5, 0 10)', 0))

INSERT INTO sample_lines
  VALUES (2, ST_LineString('linestring z 
         (0 0 4, 5 5 5, 10 10 6, 5 5 7, 0 0 8)', 0))
In the following examples, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.
Example 2
The following example removes the point (5, 5) from the linestring that has ID = 1. This point occurs twice in the linestring. Therefore, both occurrences are removed.

SELECT CAST(ST_AsText (ST_RemovePoint (line, ST_Point(5, 5, 0) ) )
  AS VARCHAR(60) ) RESULT
  FROM sample_lines
  WHERE id = 1
Results:

RESULT
------------------------------------------------------------
LINESTRING (10 10, 0 0, 10 0, 0 10)

Example 3
The following example removes the point (5, 5, 5) from the linestring that has ID = 2. This point occurs only once, so only that occurrence is removed.

SELECT CAST (ST_AsText (ST_RemovePoint (line, ST_Point(5.0, 5.0, 5.0, 0)))
  AS VARCHAR(60) ) RESULT
  FROM sample_lines
  WHERE id=2
Results:

RESULT
-------------------------------------------------------------
LINESTRING Z(0 0 4, 10 10 6, 5 5 7, 0 0 8)