2

I am currently attempting to plot AIS data from our on board AIS receiver in QGIS. (https://en.wikipedia.org/wiki/Automatic_identification_system)

My current processing steps are :-

  1. Import the AIS data as a CSV file containing Time, Vessel Name, MMSI No, Lat & Lon.
  2. Save imported data as a shapefile
  3. Remove AIS positions outside area of interest using select feature by polygon, invert selection and delete selected.
  4. Convert points to paths using order by time and group by MMSI No

This produces paths of the vessel track.

My problem is that vessels occasionally have a large gap in their AIS data that leads to un-realistic paths, i.e passing over land.

Is there are way to sort by MMSI number (Unique to each vessel) and then assign a unique cluster number to the AIS record, based on the distance between the AIS record positions for each MMSI?

i.e If a vessel has a gap in it's MMSI data of greater than 5000m assign a new cluster number to that record.

I would need to do this on a vessel by vessel basis, so that only the the AIS data for each specific vessel is examined.

If I then use points to paths and group by cluster number, it should then draw the path for all AIS data points with a gap of less than 5000m.


I followed @Spatialthoughts’ instructions and they worked perfectly.

Removing segments over 5 km long has improved the readability of the information and produces a more realistic plot of the AIS data.

AIS Data Before

AIS Data After

  • You probably want to use Group By mmsi to get groups of points and then use one of the clustering functions, such as ST_ClusterDBSCAN to eliminate groups of points more than a certain distance apart. – John Powell Aug 2 at 7:24
  • Spatialthoughts Thank you for your reply. I followed your instructions and they worked perfectly. Removing segments over 5 km long has improved the readability of the information and produces a more realistic plot of the AIS data. ![AIS Data Before](i.stack.imgur.com/nwpnV.jpg) ![AIS Data After](i.stack.imgur.com/dvQjc.jpg) – Chris Bass Aug 4 at 7:32
  • Great to hear. Chris, can you click the checkbox next to my answer to accept it? Thanks. – spatialthoughts Sep 15 at 19:20
2

Here's a workflow to plot the lines from points, excluding the parts where the gap is > 5000m

  • Points to Path algorithm, order by time and group by MMSI, results in 'paths'
  • Explode lines algorithm on 'paths', results in 'exploded'. (now the lines are split into individual segments)
  • Select by expression on 'exploded' with expression $length > 5000 . Toggle editing and delete selected segments.
  • Collect geometries algorithm, on edited 'exploded' layer, resuls in 'collected' layer.

The collected layer should have paths for each vessel with the gaps removed. You could end here, but if you really want separate groups, do the following

  • Merge lines algorithm on the 'collected' layer, results in 'merged' layer. This merges all continuous segments.
  • Multipart to singleparts algorithm on the 'merged' layer. Gives you 'singe parts' layer, which has continuous segments are separate features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.