📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ST_POINTN



Returns a Point at a specified index in a LineString.

Syntax

ST_POINTN(<geometry_or_geography>, <index>)

Arguments

ArgumentsDescription
<geometry_or_geography>The argument must be an expression of type GEOMETRY or GEOGRAPHY that represents a LineString.
<index>The index of the Point to return.

Return Type

Geometry.

Examples

GEOMETRY examples

SELECT ST_POINTN( ST_GEOMETRYFROMWKT( 'LINESTRING(1 1, 2 2, 3 3, 4 4)' ), 1 ) AS pipeline_pointn; ┌─────────────────┐ │ pipeline_pointn │ ├─────────────────┤ │ POINT(1 1) │ └─────────────────┘ SELECT ST_POINTN( ST_GEOMETRYFROMWKT( 'LINESTRING(1 1, 2 2, 3 3, 4 4)' ), -2 ) AS pipeline_pointn; ┌─────────────────┐ │ pipeline_pointn │ ├─────────────────┤ │ POINT(3 3) │ └─────────────────┘

GEOGRAPHY examples

SELECT ST_POINTN( ST_GEOGFROMWKT( 'LINESTRING(1 1, 2 2, 3 3, 4 4)' ), 2 ) AS pipeline_pointn; ┌─────────────────┐ │ pipeline_pointn │ ├─────────────────┤ │ POINT(2 2) │ └─────────────────┘

Was this page helpful?