すべてのプロダクト
Search
ドキュメントセンター

PolarDB:ST_PointN

最終更新日:Jul 01, 2024

This topic describes the ST_PointN function. This function returns the Nth point of a LineString object or circular LineString object.

構文

geometry  ST_PointN(geometry  aLinestring , integer  n);

パラメーター

項目

説明

aLinestring

The LineString object or circular LineString object that you want to specify.

n

The number of the index.

説明 

  • If you specify an object that is not a LineString object, the ST_PointN function returns NULL.

  • If the index that you specify is a negative number, this function counts the points forward from the end of the LineString object. Negative values are counted from the end of the LineString object and -1 is the last point.

  • If you want to obtain the Nth point of each LineString in a MultiLineStirng object, you must use the ST_PointN function with the ST_Dump function.

  • The ST_PointN function supports circular strings and curves.

  • The ST_PointN function supports 3D objects and does not delete z coordinates.

  • Obtain the Nth point of a LineString object by using the default parameter settings.

    SELECT ST_AsText(ST_PointN('LINESTRING(0 0,2 2)'::geometry,1));
     st_astext
    ------------
     POINT(0 0)
    (1 row)
                        
  • Obtain the Nth point of a LineString object by using the backward counting order.

    SELECT ST_AsText(ST_PointN('LINESTRING(0 0,2 2)'::geometry,-1));
     st_astext
    ------------
     POINT(2 2)
    (1 row)