Capturing raw AIS data using rtl_fm and decoding using aisdecoder v2

James Mead edited this page May 3, 2015 · 2 revisions

Capturing raw AIS data (2nd attempt)

I captured 4 x raw AIS data files by running the following commands on my Mac laptop while crossing the Solent on a WightLink car ferry which departed Yarmouth late afternoon of Sunday, 19th April:

  • rtl_fm -f 161975000 -p 45 -s 48k > 2015-04-19-test-161975000-p45-s48k.raw
  • rtl_fm -f 161975000 -p 50 -s 48k > 2015-04-19-test-161975000-p50-s48k.raw
  • rtl_fm -f 162025000 -p 45 -s 48k > 2015-04-19-test-162025000-p45-s48k.raw
  • rtl_fm -f 162025000 -p 50 -s 48k > 2015-04-19-test-162025000-p50-s48k.raw

This resulted in the following raw data files:


  • I chose the frequency (-f option) values based on the official AIS frequencies i.e. 161.975 MHz & 162.025 MHz.
  • I didn't have GQRX working on my new laptop, so I couldn't check the signal strengths and just recorded blind.
  • I chose the value of the PPM error (-p option) based on running the rtl_test command and seeing what the value settled to after a couple of minutes.

Decoding raw AIS data

I decoded the AIS NMEA sentences from the raw files captured above using aisdecoder on the Ubuntu Virtual Box VM running on my Mac laptop. I ran the following commands:

  • aisdecoder -h -p 1234 -a file -c mono -d -f 2015-04-19-test-161975000-p45-s48k.raw 2> 2015-04-19-test-161975000-p45-s48k.nmea
  • aisdecoder -h -p 1234 -a file -c mono -d -f 2015-04-19-test-161975000-p50-s48k.raw 2> 2015-04-19-test-161975000-p50-s48k.nmea
  • aisdecoder -h -p 1234 -a file -c mono -d -f 2015-04-19-test-162025000-p45-s48k.raw 2> 2015-04-19-test-162025000-p45-s48k.nmea
  • aisdecoder -h -p 1234 -a file -c mono -d -f 2015-04-19-test-162025000-p50-s48k.raw 2> 2015-04-19-test-162025000-p50-s48k.nmea

This resulted in decoded NMEA sentences in the following text files:

A total of 80 AIS sentences were decoded despite the west end of the Solent not having much shipping visible at the time.

I tried to use AGG Software's Online AIS Decoder to decode the NMEA sentences, but I kept getting an error. So I then found this Online AIS Message Decoder website which seemed to work ok. However, I also came across the gpsdecode Ubuntu package and I used this to convert my .nmea files into translated .json:

I used the following Ruby script to convert the JSON for type-1 NMEA sentences into a single CSV file:

require 'json'
require 'csv'

type_one_sentences = Dir['*.json'].map do |filename|
  lines = File.readlines(filename)
  sentences = { |line| JSON.parse(line) } { |s| s['type'] == 1 }

csv = CSV.generate do |csv|
  csv << type_one_sentences.first.keys
  type_one_sentences.each { |s| csv << s.values }

puts csv

I then imported this CSV file into Google Spreadsheets. I then manually split it into a file for each of the two car ferries mentioned (Wight Sky & Wight Sun):

Finally I imported each of these two spreadsheets into a layer on a Google Map:

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.