AIS Data Mining

Data mining large AIS data sets can reveal a lot of interesting observations. For example, using the bisecting k-means clustering algorithm, we could identify possibly interesting locations for traffic control infrastructure:


Here’s a little test we did… Wouldn’t it be nice to use supervised Machine Learning algorithms to automatically generate a suggested route for a vessel?

Using AIS data from a harbor as a training set, such an algorithm could suggest what route to follow for a particular vessel that’s navigating in the harbor.

We trained our algorithm with AIS data from the Port of Antwerp and show the suggested route in nAIS:

Route prediction in nAIS

Route prediction in nAIS

Of course, these Expert Systems need to be tested extensively and probably complemented with additional correction routines.

The .NET Micro Framework and AIS

As it says on their website, the .NET Micro Framework is .NET for small and resource constrained devices. It offers a complete and innovative development and execution environment that brings the productivity of modern computing tools to this class of devices.

So we’ve tried it with AIS. We used the FEZ Cobra from GHI Electronics with the 3.5” touch screen:

cobra1       cobra2

Then we added a GPS receiver and implemented an embedded AIS vessel plotter. The GPS we used is the FV-M8 model from San Jose Navigation:


The device we used runs on 6V. This can be provided by batteries or an adapter. The GPS also needs a small backup battery. Without an external backup battery, the GPS will execute a cold start after every turn on. Anything between 2V and 5V should do to achieve fast GPS start-ups.

We wired the GPS to the UEXT connector pins (3.3V, GND, COM1TX and COM1RX) and supplied the backup battery power as mentioned before. Optionally, an external GPS antenna could be used, or the position could be retrieved from an external GPS device.

The vessel plotter we implemented supports dynamic, static and voyage related information, plots vessels in vicinity of your own position, has 9 range scales (0.1 Nm to 10 Nm), has a configurable proximity alarm (.05 Nm to 10 Nm with mandatory confirmation), has “target lost” indication, shows extended ship information and visualizes Rate Of Turn, Heading, Course Over Ground and projected routes of vessels.

WP_000345       WP_000346

The FEZ Cobra board has several options for receiving an AIS stream. With the ethernet port or the optional Wi-Fi module, the AIS stream could be dispatched directly to the device, for example using AIS Dispatcher.

Since the EMX module supports USB Host, another option could be to connect a receiver – such as the MarineGadget AIS receiver – to the USB port of the device. These approaches would require a .NET Micro Framework AIS parser implementation to process the AIS stream on the device.

Alternatively, the AIS data could be retrieved using web service calls. We will use this approach and make REST HTTP calls to our AIS web services. Again, there are several options to do this. We could add a wireless module and call the services over Wi-Fi, we could add a cellular radio module to reach the services over the internet, or we could just use the ethernet port on the device to connect to services on a LAN or on the internet, which is what we did here.

AIS message type 1: Position report class A (scheduled) + manual decoding

In this post I will discuss AIS message type 1, which is a position report. Together with message type 2 and 3 it is also called the Common Navigation Block (CNB).

I will explain message type 1 using an example, which I will decode manually only using a calculator, when I become too lazy to do the calculations by hand, because binary operations on large numbers get rather tedious after a while.

Our sample message:

We will focus on the content of this AIVDM message for now:

Message type 1 has a length of 168 bits. If you count the number of characters of the content of the message above, you will get 28 as a result. I know this without counting them, because AIS encodes messages using a 6-bits ASCII mechanism and 168 divided by 6 is 28.

So, how does this work?

The table below lists the characters of the content of the message in the left column:


The first column shows the characters of the message’s content. The second column gives the ASCII code for that character. Now, the next column, labeled Decimal, shows the values of the ASCII code minus 48, but if the result of that operation is larger than 40, you also subtract 8 of that remaining value.

An example:
8 has 56 as ASCII code. 56 minus 48 is 8. 8 is smaller than 40, so 8 is the final result.
w has 119 as ASCII code. 119 minus 48 gives you 71. 71 is bigger than 40. So, you subtract 8, which results in 63. Done!

If you repeat this for all characters, the third column above is what you will get. Now, write down the 6-bit binary representation of these numbers (fourth column).

This results in the following bit stream:
000001 000011 000011 110101 010000 110111 101111 100000 000000 000000
100000 010100 001011 001000 001000 011101 010100 000101 011101 100100
010100 111111 111111 010000 000010 010100 000111 110011

We split the message according to the decoding specifications of this message:


The decimal value of 000001 (the binary representation of the field Message Type) is 1, which should not be a surprise. We are dissecting an AIS message of type 1 and that’s exactly what we have here.

The repeat indicator is 0.

The MMSI has a length of 30 bits. It is an unsigned integer, so that is an easy one. We’ll take the Windows calculator and put it in Programmer’s view. We enter the 30 bits in binary mode and when we change it to decimal mode, we get the MMSI of the vessel: 205344990.

calc1   calc2

The navigation status: 1111, which gives us 15. This field refers to an enumeration of predefined values. 15 means “Not defined”, which is the default value for this field.

The Rate of Turn is a signed integer. To get the decimal representation, you have got to use two’s complement: 10000000 => –128. This means that there is no turn information available (again this is the default value).

Speed over ground is an unsigned integer, 0 in this message. So, the ship is not moving.

Position accuracy is 1. This field is of type boolean, so 1 is true.

The longitude and the latitude values are also unsigned integer, but the decimal values should be divided by 10000 to obtain the longitude and latitude in minutes:
- longitude: 0000001010000101100100000100 => 2644228; divided by 10000 => 264.4228’ => 4° 24.4228’
- latitude: 001110101010000010101110110 => 30737782; divided by 10000 => 3073.7782 => 51° 13.7782’

For the Course over ground field (length in bits: 12):  010001010011, we find a value of 1107. This should be divided by 10, which gives us 110.7°

The rest of the exercise is easy.

True heading has a value of 511, which means that it is not available.

Time stamp is 40.

Maneuver indicator is 0 and the RAIM flag is set to true.

The last 19 bits represent a SOTDMA radio status message. We will talk about that in another post.

So, what does this message tell us? We know from the content that the vessel with MMSI 205344990 is at position: latitude: 51° 13.7782’’ and longitude: 4° 24.4228. Its position is accurate and it is not moving.

Posted in AIS

MarineGadget AIS receiver

A couple of weeks ago I have bought a MarineGadget Radar AIS receiver from “Radar Gadgets” ( I have tested it and it works like a charm. It is easy to set up and to get it working. This article explains which steps you have to take to get this tiny device going.

If you receive the MarineGadget AIS receiver, you will get a large brown envelope, which contains the following:

  • a CD containing the necessary drivers to get the device talking to your computer
  • a USB extension cable
  • an installation manual, which you will only really need for the commands you can send to the AIS receiver to configure it (more on this topic later in this post)
  • and of course, a USB AIS receiver


Equipment needed

You will need a computer with a free USB port and a marine VHF antenna. I have chosen for a laptop running Windows 7 Professional.




You will have to make sure that you will be able to connect the VHF antenna to the MarineGadget AIS device. The receiver has a female SMA connector for the antenna input, but it is delivered with a male SMA – female BNC adapter. The VHF marine antenna I own has a male PL-259 connector. Luckily, I have a male BNC – female PL-259 adapter, so I can connect everything together.


The work on the computer

Put the AIS receiver in a free USB port. Windows will try to find the appropriate drivers for the device, but that will fail. Ask Windows to search for drivers on the CD delivered with the receiver and voilà, the OS has recognized the device, has found the appropriate drivers and hence, is able to communicate with it. To make sure this action has been accomplished successfully and to find out which COM port you will have to use to talk to the device, open Start > Control Panel > Hardware and Sound > Device Manager.

Under the Ports (COM & LPT) branch of the devices tree you will notice that a new device has appeared: “MarineGadget Radar Comms Port (COM9)”.


We are almost there. As a serial terminal emulator program, I will use Putty. It is free and does its job well. Connect Putty to the COM 9 port using the following parameters (baud rate 38400 bps):


If you hit the Open button, AIS message sentences will start to roll over your screen:


One last thing, if you look closely to the image above, you only see channel B messages. The AIS receiver of MarineGadget can listen to only one channel at a time. So, you can configure it to listen to Channel A (161.975 MHz) or Channel B (162.025 MHz) continuously or you tell it to switch between the two channel frequencies at a regular time interval. How do you do this? When connected to the receiver with a terminal emulator, just type one of the following commands:

  • RADFA: Channel A is set all the time
  • RADFB: Channel B is set all the time (default)
  • RADF1: Alternative Channel A and Channel B every 10 seconds
  • RADF2: Alternative Channel A and Channel B every 20 seconds
  • RADF3: Alternative Channel A and Channel B every 30 seconds
  • RADF4: Alternative Channel A and Channel B every 40 seconds
  • RADF5: Alternative Channel A and Channel B every 50 seconds

The receiver only demodulates AIS messages of these types: 1, 2, 3, 4, 5, 9, 18, 19, 21 and 24.

The end.

Posted in AIS

The very first post

Starting today posts about the following topics will start to appear here:

  • the adventures of the company it-digin
  • AIS: Automatic Identification System
  • NUI: natural user interfaces

The first series of posts will address the 27 different top-level messages as defined in the ITU Recommendation M.1371-4 (04/10):

00: Undefined
01: Position report
02: Position report
03: Position report
04: Base station report
05: Static and voyage related data
06: Binary addressed message
07: Binary acknowledgement
08: Binary broadcast message
09: Standard SAR aircraft position report
10: UTC/Date inquiry
11: UTC/Date response
12: Addressed safety related message
13: Safety related acknowledgment
14: Safety related broadcast message
15: Interrogation
16: Assignment mode command
17: DGNSS broadcast binary message
18: Standard class B equipment position report
19: Extended class B equipment position report
20: Datalink management message
21: Aids-to-navigation report
22: Channel management
23: Group assignment command
24: Static data report
25: Single slot binary message
26: Multiple slot binary message with Communications state
27: Position report for long-range applications
28-63: Reserved for future use

We will cover them one by one …


Posted in AIS