This topic describes the ST_Density function. This function calculates the density of a trajectory. The density of a trajectory indicates the number of points in the neighborhood of the trajectory.

Syntax

integer[] ST_Density(trajectory traj, float dr, interval dt);

Parameters

Parameter Description
traj The trajectory that you want to calculate.
dr The spatial range of the neighborhood.
dt The time range of the neighborhood.

Description

This function calculates the total number of sampling points that belong to a trajectory in the neighborhood. If the spatial distance between a sampling point and the selected trajectory point is less than the value of the dr parameter and the time range between them is less than the value of the dt parameter, the sampling point is in the neighborhood of the selected trajectory point. The spatial distance is calculated based on the spatial reference identifier (SRID) of the trajectory point. Each point is always in its own neighborhood.

Examples

select ST_Density(st_makeTrajectory('STPOINT'::leaftype, ARRAY[1::float8, 2, 3 ,4, 5],
                                   ARRAY[2::float8, 10, 9, 8, 7], 4326, ARRAY['2010-01-01 11:30'::timestamp,
                                    '2010-01-01 11:31','2010-01-01 11:32','2010-01-01 11:33','2010-01-01 11:34']), 400000, '10 minute');
 st_density
-------------
 {1,3,4,4,3}
(1 row)