All Products
Search
Document Center

ApsaraDB RDS:ST_CurvatureRadius

Last Updated:Mar 28, 2026

Returns the curvature radius at each intermediate point of a trajectory as an array of double-precision floating-point values.

Syntax

double precision[] ST_CurvatureRadius(trajectory traj, boolean hasdirection default false);

Parameters

ParameterDescription
trajThe trajectory object.
hasdirectionSpecifies whether to calculate the direction of rotation of the trajectory. When set to true, a negative value is returned when the trajectory is rotated in the counterclockwise direction. Default: false.

Description

ST_CurvatureRadius computes the curvature radius at each intermediate point of a trajectory. For a trajectory with *n* points, there are *n* − 2 intermediate points (all points except the first and last).

Return values follow these rules:

  • `Infinity` — the trajectory moves in a straight line or remains stationary at that point.

  • Negative value — the trajectory curves counterclockwise at that point (only meaningful when hasdirection is true).

  • Smaller absolute value — a sharper curve.

Examples

The following examples use ST_MakeTrajectory to construct trajectory objects from LINESTRING geometries.

5-point trajectory (straight segments and one curve)

-- A 5-point trajectory produces 3 intermediate points.
-- The first intermediate point has a 90-degree turn with radius 5;
-- the remaining two are on a straight line and return Infinity.
SELECT ST_CurvatureRadius(
  ST_MakeTrajectory(
    'STPOINT'::leaftype,
    'LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8)',
    '2000-01-01',
    '2000-01-01'::timestamp + '1 day'::interval * (ST_NPoints('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8)') - 1),
    '{}'
  )
);

Result:

  st_curvatureradius
-----------------------
 {5,Infinity,Infinity}

8-point trajectory (two symmetric curves, no direction)

-- An 8-point trajectory produces 6 intermediate points.
-- Two turns have radius 5; straight and stationary segments return Infinity.
SELECT ST_CurvatureRadius(
  ST_MakeTrajectory(
    'STPOINT'::leaftype,
    'LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0)',
    '2000-01-01',
    '2000-01-01'::timestamp + '1 day'::interval * (ST_NPoints('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0)') - 1),
    '{}'
  )
);

Result:

    st_curvatureradius
--------------------------
 {5,Infinity,Infinity,Infinity,Infinity,5}

8-point trajectory (two curves, with direction)

-- Same trajectory as above, but with hasdirection=true.
-- The last turn is counterclockwise, so its radius is returned as -5.
SELECT ST_CurvatureRadius(
  ST_MakeTrajectory(
    'STPOINT'::leaftype,
    'LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0)',
    '2000-01-01',
    '2000-01-01'::timestamp + '1 day'::interval * (ST_NPoints('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0)') - 1),
    '{}'
  ),
  true
);

Result:

    st_curvatureradius
--------------------------
 {5,Infinity,Infinity,Infinity,Infinity,-5}

10-point trajectory (multiple curves, with direction)

-- A 10-point trajectory produces 8 intermediate points.
-- Results include radius 5, -5 (counterclockwise), 0 (instantaneous reversal), and 2.5.
SELECT ST_CurvatureRadius(
  ST_MakeTrajectory(
    'STPOINT'::leaftype,
    'LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0, 0 4, 3 4)',
    '2000-01-01',
    '2000-01-01'::timestamp + '1 day'::interval * (ST_NPoints('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0, 0 4, 3 4)') - 1),
    '{}'
  ),
  true
);

Result:

   st_curvatureradius
-----------------------
 {5,Infinity,Infinity,Infinity,Infinity,-5,0,2.5}

See also

  • ST_MakeTrajectory — constructs a trajectory object from a geometry and time range

  • ST_NPoints — returns the number of points in a geometry