[GIS] Storing GPS tracks with timestamps in PostGIS

gpsmovement-datapostgistracklog

I need to store a series of GPS points with timestamps in the database (traces of various vehicles).

I am wondering which of two approaches to choose for storing them in the PostGIS table:
1.) Each point in own row with separate column for timestamp and one for track ID

2.) Use Linestring or MultiLineString with fourth M coordinate which would contain UNIX timestamp of the time for the point on the track. This would mean single row for each separate track.

Best Answer

Personally I store data collected by my GPS unit as a point layer with a time stamp field, then I can use ST_Makeline if I need the line strings. If you have Postgres 9.0+ you can use an ORDER BY in your aggregate calls to make sure the line goes from point to point in chronological order. I lose the M values along the created lines, but if I need them I always have the point layer I can throw on in the background.

Related Question