GanosBase provides four categories of functions for preprocessing trajectory sampling points: filtering, segmentation, resampling, and simplification. These functions are available starting from GanosBase version 5.2 and help you clean noisy GPS data, split trajectories into meaningful segments, correct uneven point distribution, and reduce data volume for efficient rendering and storage.
Background
Trajectory data model
Trajectories are spatiotemporal objects that represent the movement of objects such as pedestrians, vehicles, ships, and aircraft.
A trajectory can be analyzed in two ways:
Discrete points: A set of individual sampling points, each with a timestamp, spatial coordinates, and optional attributes such as speed. Point-based representations are used for similarity calculations and segmentation algorithms.
Continuous polyline: A spatial polyline that evolves over time. Less sensitive to sampling frequency, and supports the full range of spatial operations available for polylines.
For example, a shared bicycle reports its coordinates at specific moments. The database stores these as records:
| Time | x | y | Speed |
|---|---|---|---|
| 2020-04-11 17:42:30 | 114.35 | 39.28 | 4.3 |
| 2020-04-11 17:43:30 | 114.36 | 39.28 | 4.8 |
| 2020-04-11 17:45:00 | 114.35 | 39.29 | 3.5 |
These points form a spatiotemporal trajectory:

GanosBase extends PolarDB with the trajectory type, spatial indexing, and spatiotemporal operators to support storage, retrieval, and analysis of moving objects.
Common data quality issues
In most deployments, trajectories are collected by systems such as Transportation Management Systems (TMS) and Automatic Identification Systems (AIS) based on GPS signals. Even with consistent GPS sampling frequency, the following issues can degrade data quality:
Drift points: Abnormal positions caused by poor GPS signal quality, where a point deviates significantly from the expected motion pattern.
Excessive stationary points: Redundant points recorded when an object is stationary, such as ships circling a port while waiting for a berth, or vehicles resting at service areas.
Uneven point distribution: Gaps caused by signal loss or preprocessing steps, which can introduce errors in analysis such as similarity calculations.
Large data volumes: High-density sampling that reduces frontend rendering performance and can cause application failures.
Processing functions
Trajectory filtering: ST_removeDriftPoints
ST_removeDriftPoints removes points that deviate significantly from the expected motion pattern. It targets two types of anomalies:
Positional drift: Points displaced from the actual path due to sampling errors.
Speed anomalies: Artificial speed spikes caused by dense but imprecise sampling, where an object appears to jump within a short time frame.

For the full function signature and parameters, see .
Trajectory segmentation: ST_Split
ST_Split divides a trajectory into multiple sub-trajectories using geometric objects. It supports three segmentation modes. Choose the mode based on whether you want to split at an existing point, an interpolated point, or remove a segment entirely.
cut_point
Splits the trajectory at a specific existing sampling point. Both resulting sub-trajectories include the split point.
Use this mode when a trajectory is too long and needs to be divided into shorter segments for analysis or processing.
cut_edge
Similar to cut_point, but the split position is not limited to existing sampling points. The split can occur at an interpolated point derived from the trajectory boundaries, such as a time-based or grid-based intersection. Both resulting sub-trajectories include the interpolated point.
Use this mode to divide trajectories into fixed spatial or temporal shapes, such as grid cells or fixed-duration intervals.
drop_edge
Removes a selected edge from the trajectory. The two endpoints of the deleted edge each become the endpoint of a separate sub-trajectory, so the removed segment is excluded from all results.
Use this mode to discard stationary or irrelevant segments. For example, when analyzing shared bicycle trips, drop stationary periods when the bicycle is parked and retain only the active travel segments.

For the full function signature and parameters, see .
Trajectory resampling: ST_Resample
ST_Resample corrects uneven point distribution that can result from noise reduction or other preprocessing steps. Uneven distribution degrades the performance and accuracy of local trajectory segment analysis.
GanosBase provides two resampling strategies:
add_point: Increases point density along the trajectory. Use for detailed analysis tasks such as density statistics or similarity matching.
drop_point: Decreases point density along the trajectory. Use to extract long-term movement trends or simplify the trajectory before further processing.
For the full function signature and parameters, see .
Trajectory simplification
Trajectory simplification (also called trajectory lossy compression) reduces the number of sampling points in a trajectory while preserving its overall movement direction. This decreases storage requirements and improves rendering performance.

GanosBase provides two simplification functions. Choose based on whether your trajectory includes timestamps:
| Function | Algorithm | When to use |
|---|---|---|
ST_Compress | Douglas-Peucker | Two-dimensional (2D) trajectories without timestamps; all points must lie on the same plane |
ST_CompressSED | Synchronized Euclidean Distance (SED) | Spatiotemporal trajectories with timestamps; use this when the trajectory includes a time dimension |
Why use ST_CompressSED for timestamped trajectories
The Douglas-Peucker algorithm measures perpendicular distance in 2D space. When a moving object remains stationary for a prolonged period, the 2D projection of its path collapses multiple points into one location. Applying the 2D algorithm in this case can eliminate one endpoint of the stationary segment, distorting the three-dimensional (3D) structure of the trajectory.
ST_CompressSED replaces perpendicular Euclidean distance with Synchronized Euclidean Distance (SED), which accounts for the time dimension. This ensures accurate compression of spatiotemporal trajectories without distorting stationary periods.
If your trajectory data includes timestamps, use ST_CompressSED instead of ST_Compress. Using ST_Compress on timestamped trajectories can distort stationary segments in the 3D structure.
For the full function signatures and parameters, see and .
Best practices
Case 1: Remove drift points from ship AIS data
To build an accurate ship navigation trajectory from AIS data, extract latitude and longitude from the point table, construct a trajectory object, apply drift point removal, and store the cleaned result.
SELECT
ST_removeDriftPoints( -- Remove drift points
ST_SetSRID( -- Assign spatial reference ID (SRID)
ST_MakeTrajectory( -- Build a trajectory object from raw points
ARRAY_AGG(
ROW(
traj.arrival_time::TIMESTAMP,
st_x(traj.pts)::DOUBLE PRECISION,
traj.lat::DOUBLE PRECISION,
traj.rowid
)
),
FALSE,
'{"rowid"}'::cstring[]
),
4326 -- WGS 84 coordinate system
),
40, -- Maximum allowed speed deviation
10, -- Minimum number of points to evaluate
'1 minute'::INTERVAL -- Minimum time gap threshold
)
FROM (
SELECT
time,
ST_makepoint(lon, lat) pts,
lat,
rowid
FROM point_table
WHERE
time IS NOT NULL
AND lon IS NOT NULL
AND lat IS NOT NULL
ORDER BY rowid
) traj INTO trajectory_table;The query returns a cleaned trajectory object stored in trajectory_table, with drift points removed. You can then use this trajectory for navigation analysis or further processing.
Case 2: Resample drone trajectory points and calculate point density
To analyze drone movement patterns, segment the trajectory into 5-minute intervals, resample within each interval, calculate point density, and feed the result into a machine learning model.
SELECT
ST_Density(
ST_Resample(
ST_OnlyST(traj),
'{"add_point.period_lesser":"5 minute"}' -- Add points at intervals shorter than 5 minutes
),
100,
'30 minute'
)
FROM table;The query returns a density value for each 30-minute window, calculated from resampled points. Use this output as input features for your machine learning model.
Case 3: Extract specific journey segments from freight vehicle data
A freight management customer processes extensive vehicle trajectory data and needs to focus on specific journey segments. By removing longer edges based on spatial distance, longer stationary or transition segments are discarded, leaving shorter and analyzable sub-trajectories.
WITH traj AS (
SELECT
'{"trajectory":{"version":1,"type":"STPOINT","leafcount":19,"start_time":"2000-01-01 00:01:19.067179","end_time":"2000-01-01 03:24:25.946085","spatial":"LINESTRING(-100 -100 -100,-88.8925775739675 -86.6512698383691 -92.3767832526937,-79.6904716538265 -80.6515727923252 -84.2357598245144,-75.8435507711644 -73.7572890928326 -80.5007370118983,-70.6238425321256 -67.8213750167439 -74.5733173238113,-61.6014582272619 -61.0636760429479 -67.9874239303172,-56.1098577060426 -54.4264591250879 -64.5007972046733,-46.9800617334743 -49.4026757289345 -61.6160059720278,-41.7122942996211 -46.3224360072054 -56.5283147455193,-35.5646221285375 -38.1688933617746 -49.2775720101781,-31.7230528349367 -33.6970051738123 -44.1693710885011,-23.1585765127093 -26.5895827477798 -40.6539742602035,-16.7020264320696 -21.6133877349397 -37.3055470525287,-12.1044529232507 -14.1236051704424 -28.2295028120279,-3.77185660181567 -7.74744770256802 -24.3842111621052,0.488159407706304 -3.68223926316326 -19.9478872027248,6.33406881305078 4.54123636645575 -15.0410129944794,15.6666049417108 10.5611746329814 -11.2770220567472,14 11 -10)","timeline":["2000-01-01 00:01:19.067179","2000-01-01 00:12:36.116007","2000-01-01 00:23:53.164835","2000-01-01 00:35:10.213663","2000-01-01 00:46:27.262491","2000-01-01 00:57:44.311319","2000-01-01 01:09:01.360147","2000-01-01 01:20:18.408975","2000-01-01 01:31:35.457803","2000-01-01 01:42:52.506631","2000-01-01 01:54:09.555459","2000-01-01 02:05:26.604287","2000-01-01 02:16:43.653115","2000-01-01 02:28:00.701943","2000-01-01 02:39:17.750771","2000-01-01 02:50:34.799599","2000-01-01 03:01:51.848427","2000-01-01 03:13:08.897255","2000-01-01 03:24:25.946085"]}}'::trajectory AS a
)
SELECT (ST_split(a, '{"drop_edge.spatial_distance_2d":10}')) -- Remove edges longer than 10 units in 2D space
FROM traj;The query returns an array of sub-trajectory objects. Each sub-trajectory represents a distinct journey segment with edges longer than 10 spatial units removed.