Skip to main content

DK AIS [dkais]

PyPI - Version PyPI - Downloads GitHub Actions Workflow Status Open In Colab

This Python package streamlines the download and processing of historical Automatic Identification System (AIS) data provided by the Danish Maritime Authority (DMA).

AIS is a maritime navigation safety communications system standardised by the International Telecommunication Union (ITU) and adopted by the International Maritime Organization (IMO). AIS is a VHF-based navigation and anti-collision tool making it possible to exchange information between ships.

For more information about AIS, including its history, functionality and applications - see Wikipedia.

https://github.com/user-attachments/assets/b809ad7f-fca4-404a-9a1e-20e29a72d7e8

Usage

dkais mirrors the public bucket to a data directory and converts each daily CSV to Parquet. Set the directory once with DKAIS_DATA_DIR (or pass --data-dir to any command).

dkais list --start 2026-10                       # archives & local state
dkais download --start 2026-10 --end 2026-10-07  # zips to <data-dir>/raw
dkais process --start 2026-10 --end 2026-10-07   # to <data-dir>/parquet

dkais <command> --help lists a command's options and examples. list --json emits machine-readable output, download -j N sets concurrent downloads (default 4) and process --force re-converts days that already have Parquet output. download -n and process -n (--dry-run) print what they would do to STDERR and stop, changing nothing.

list prints a table on a terminal and, when piped or with --plain, one tab-separated row per archive - the --json keys in order, without a header. download and process end with a key=value line when piped or with --plain. Every command takes -q (no informational output), --no-color and --no-input; FORCE_COLOR forces colour only, and TTY_COMPATIBLE=1 asks for the terminal layout on a pipe. Add -d before or after any command for debug logging. Exit codes are 0 for success, 1 for a failure (e.g. a failed download), 2 for a usage error, 70 for an unexpected error - a bug, please report it - and 130 for Ctrl-C.

Dates are YYYY, YYYY-MM or YYYY-MM-DD and inclusive. download and process need --start or --all - the full bucket is ~4.2 TB compressed. download --all names the archive count and size and asks before it starts; --force skips the question. Scripts must pass --force, since download --all exits 2 rather than ask unless STDIN and STDERR are both terminals, and always with --no-input. download fetches whole archives (monthly up to 2024-02, daily since), while process converts only the days in range. Both skip completed work, so an interrupted run resumes where it stopped. process works offline from <data-dir>/raw.

<data-dir>/
  raw/YYYY/aisdk-YYYY-MM[-DD].zip
  parquet/YEAR=2026/MONTH=10/aisdk-2026-10-18.parquet
  tmp/

process unzips the next day while converting the current one. A day's CSV is held in memory when five times its size is available (a 3 GB daily CSV needs ~15 GB), otherwise it is extracted to <data-dir>/tmp. Unzipping uses zlib-ng, either from the zlib-ng package or the standard library where it is built in (CPython 3.14+ on Windows).

Each Parquet file holds one day: all 26 DMA columns renamed to UPPER_SNAKE and typed, sorted by MMSI and DATETIME. AIS "not available" values (latitude 91, longitude 181, heading 511, Unknown IMO/callsign/destination) become null, and no rows are dropped. The three historical CSV dialects (comma with 22 columns, header-less semicolon with decimal commas, comma with 26 columns) share one output schema.

import polars as pl

ais = pl.scan_parquet("<data-dir>/parquet", hive_partitioning=True)
october = ais.filter(pl.col("YEAR") == 2026, pl.col("MONTH") == 10)

Dataset

Metadata

  • Identifiers - ship name, call sign or IMO number & MMSI number
  • Navigation - position, course & speed
  • Voyage - destination, ETA & actual draught

Veracity

Information received by AIS originates from the ships' own instruments. There can be errors in the information inserted or technical defects that may give an erroneous impression of the ship's speed or position.

AIS contributes to safety of navigation and has, in many ways, made it easier to navigate safely. However, AIS also has some limitations that it is important to take account of. If you trust your AIS data uncritically, it may be risky.

Features

See the table below, for the original DMA dataset features and the new feature names in the typed Parquet files after dkais processing.

Original Processed Type Comment
Timestamp DATETIME datetime[μs] dd/mm/yyyy HH:MM:SS
Type of mobile MOBILE_TYPE cat Vessel class
MMSI MMSI i32 Maritime Mobile Service Identity (unique 9-digit number)
Latitude LATITUDE f64 Decimal degrees, null if 91 (not available)
Longitude LONGITUDE f64 Decimal degrees, null if 181 (not available)
Navigational Status NAV_STATUS cat Navigational status (AIS metadata)
ROT ROT f32 Rate of Turn (AIS metadata)
SOG SOG f32 Speed Over Ground (AIS metadata)
COG COG f32 Course Over Ground (AIS metadata)
Heading HEADING i16 Heading (AIS metadata), null if 511 (not available)
IMO IMO i32 International Maritime Organization number, null if Unknown
Callsign CALLSIGN str Callsign of the vessel, null if Unknown
Name NAME str Name of the vessel
Ship type SHIP_TYPE cat Type of ship (AIS metadata)
Cargo type CARGO_TYPE cat Type of cargo (AIS metadata)
Width WIDTH i16 Width of the vessel
Length LENGTH i16 Length of the vessel
Type of position fixing device POSITION_DEVICE cat e.g. GPS, GLONASS, Galileo, Surveyed
Draught DRAUGHT f32 Draught of the vessel (AIS metadata)
Destination DESTINATION str Destination of the vessel (AIS metadata), null if Unknown
ETA ETA datetime[μs] Estimated Time of Arrival, dd/mm/yyyy HH:MM:SS
Data source type DATA_SOURCE cat e.g. AIS
A SIZE_A i16 Length from GPS to the bow, null in 22-column files
B SIZE_B i16 Length from GPS to the stern, null in 22-column files
C SIZE_C i16 Length from GPS to starboard side, null in 22-column files
D SIZE_D i16 Length from GPS to port side, null in 22-column files

Metadata

Release files for dkais 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dkais 0.4.0
File Size Uploaded Provenance Actions
dkais-0.4.0.tar.gz 28.3 kB Without provenance Details for dkais-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dkais 0.4.0
File Interpreter ABI Platform Actions
dkais-0.4.0-py3-none-any.whl Python 3 none any Details for dkais-0.4.0-py3-none-any.whl

Total release size: 58.6 kB

Release files / dkais-0.4.0.tar.gz

Download URL dkais-0.4.0.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
527b2afb78770656c6edbf6fb001492c09cd3d226eb77d875f602e0c18f1ab10
BLAKE2b-256 checksum
How to use checksums
e4c148c6d42c855ccb6e695bdbf7ac255b68e36230405f09232986ed034f668d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / dkais-0.4.0-py3-none-any.whl

Download URL dkais-0.4.0-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e721b1c9585b5a0e1e6724a8aa4fee2ad408ba6e6390a6437bc59800f463b34
BLAKE2b-256 checksum
How to use checksums
9096193a7860d45423483cfc62e8807c3475ee2667746ebcb34663bc6a9143b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for dkais 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page