Closed mnaranjo closed 5 months ago
Hey @mnaranjo,
which country code are you referring to? As far as I know, there are two types of "country codes" in AIS messages:
Neither is currently implemented in pyais. Support for the MID could easily be added. The latter is a rather rare type of message that is very specific and almost never occurs in real world scenarios. Therefore, I am a bit hesitant to add support for this subtype.
Hi @M0r13n , I was referring to the possibility to know the flag of the ship, i.e. to know which country each ship belongs to when data is collected.
@mnaranjo This can only be achieved by examining the first digits of the MMSI. These two articles explain how this works:
As of right now, pyais does not provide the functionality to extract the country/flag from the MMSI. However, I believe that I will add this feature in the near future
Thank you very much for your help.
Hey @mnaranjo,
with the newest version of pyais you can get the country code and name:
from pyais.util import get_country
# The first 3 digits of any MMSI number are indicative of the vessel's flag
country_code, country_name = get_country(249110000)
assert country_code, country_name == ('MT', 'Malta')
Hello,
What would I have to do to obtain the 'country code' of a vessel?
Thank you in advance