ST_StartPoint function
The ST_StartPoint function takes a curve as an input parameter and returns the point that is the first point of the curve.
The resulting point is represented in the spatial reference system of the specified curve. This result is equivalent to the function call ST_PointN(curve, 1)
If the specified curve is null or is empty, then null is returned.
Syntax
Parameters
- curve
- A value of type ST_Curve or one of its subtypes that represents the geometry from which the first point is returned.
Return type
ST_Point
Example
In the following example, two linestrings
are added to the SAMPLE_LINES table. The first one is a linestring
with X and Y coordinates. The second one is a linestring with X, Y,
and Z coordinates. The ST_StartPoint function is used to return the
first point in each linestring.
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 (1, ST_LineString ('linestring z
(0 0 4, 5 5 5, 10 10 6, 5 5 7, 0 0 8)', 0))
SELECT id, CAST( ST_AsText( ST_StartPoint( line ) ) AS VARCHAR(80))
START_POINT
FROM sample_lines
Results:
ID START_POINT
----------- --------------------------------------------
1 POINT (10 10)
1 POINT Z(0 0 4)