sailing   salts

Enter what you want to search for, to search for an "exact phrase" by enclosing it in quotes. You may search for a combination of words and phrases


Learn more about our "How to Tie Knots" DVD/CD
July 21st 2024 - 09:26
July 20th, 2007
July 20th, 2007

Decoding AIS Data

For the last month or so I have been scouring the Internet trying to figure out how to decode the encoded data that comprises the AIS messages in NMEA format - I finally figured out how to do it...

I never understand why some of these things are such a great trade secret - itīs really quite simple. In my quest to find the answer I found literally hundreds of forum posts from various people asking how to do it. I also found many commercial packages that can be used for application developers that provide a library that does it - all for at least $1000

So - here is the drill - Itīs really simple and I plan to create 2 libraries on in Java and the other in PHP that will do this and give them away fro free.

For now, Iīll just explain it:

Here is a typical AIS NMEA message:


In Order:

!AIVDM:        The NMEA message type
1              Number of Sentences (some messages need more then one)
1              Sentence Number (1 unless itīs a multi-sentence message)
               The blank is the Sequential Message ID (for multi-sentence messages)
A              The AIS Channel (A or B)
14eG;...       The Encoded AIS Data (more on this later)
0*             End of Data
7D             NMEA Checksum (more on this later)

For most programmers that part was the easy part - itīs just a comma delimited list of data elements. Not the tricky bit - the encoded AIS data...

in NMEA encoding for AIS - each ASCII characters corresponds to 6 binary bits (unlike normal ASCII which uses 8 bits) so you need to step through each character and subtract 48 from the ASCII - then if itīs still a decimal number > 40 subtract another 8 - then convert to binary: this guarantees a 6 bit number. Looking at our data (just the first few characters)


1 = 000001
4 = 000100
e = 101101
G = 010111
and so on...

The complete data string decoded looks like this when strung Back together.
000001 000100 101101 010111 011100 001010 010000 000000 000000 000000 110111 001000 110111 100001 101000 011100 011101 110010 011111 101011 110000 110101 010111 010000 000000 001000 011000 011011

Now you start grabbing sets of bits from this and converting to decimal. Here are the key pieces of information assuming the first character is a ī1ī (the message type):

MMSI Number - Starting from bit 8 for 30 bits
            = 010010110101011101110000101001 = 316005417

HDG - bit 128 for 9 bits
COG - bit 116 for 12 bits (and divide by 10)
SOG - bit 50 for 10 bits (and divide by 10)

Lat - bit 89 for 27 bits (a signed binary number, divide by 600000)
Lon - bit 61 for 28 bits (a signed binary number, divide by 600000)

Thatīs the key info. I plan to write a complete article on this for the benefit of the net community - but this is a quick summary for those that have been looking for a long time now.

Form more see our developing AIS Information page

Share this:
Comments (2 )
Following your method I have written a Delphi program to decode the AIS data.
July 27th, 2010 09:25:25
Hi there, this is interesting, can I ask where can I download the java/php libs?
cheers Ben
November 16th, 2011 19:36:27
You must login or register to post comments Login/Signup
RSS feed Feed Description
Subscribe to the complete The Bosunīs Mate News RSS news feedAll News RSS feed Complete RSS feed
Subscribe to the The Bosunīs Mate News RSS news feed for this category onlyBosunīs Log RSS feed for: Bosunīs Log
A Rich Site Summary (RSS) feed is an xml data file that provides a summary of the information contained here. It is not designed to be viewed in your browser, but instead by rss reader software. If you do not know what this means - you can safely ignore it, as it is provided for advanced users with rss reader software only.

wooden boats
Copyright © 1987-2024 The Bosun's Mate