| Title: | Processing and Analyzing AIS Vessel Tracking Data |
|---|---|
| Description: | Processes Automatic Identification System (AIS) vessel tracking data, including travel estimation, trajectory correction, interpolation, extraction, and summarising vessel information. The package is designed to facilitate reproducible analyses of maritime traffic in ecological, environmental, and marine spatial planning applications. For more details see <https://remip48.github.io/AISanalyze/>. |
| Authors: | Rémi Pigeault [aut, cre] (ORCID: <https://orcid.org/0000-0003-2714-5122>) |
| Maintainer: | Rémi Pigeault <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 3.1.4 |
| Built: | 2026-10-09 13:00:08 UTC |
| Source: | https://github.com/remip48/aisanalyze |
A subset of Automatic Identification System (AIS) messages collected in the North Sea on 1 November 2022. The dataset contains vessel positions together with static and dynamic AIS information, including vessel identity, navigational status, speed, heading, dimensions, draught and destination.
A data frame with AIS messages for multiple vessels. The main variables include:
Date and time of the AIS message (UTC).
Anonymized Maritime Mobile Service Identity (MMSI) of the vessel.
Longitude (decimal degrees, WGS84).
Latitude (decimal degrees, WGS84).
Reported navigational status.
Speed over ground (knots).
True heading (degrees).
Reported International Maritime Organization (IMO) number.
Reported vessel type.
Reported vessel length (m).
Anonymized vessel name.
Reported vessel width (m).
Reported vessel draught (m).
The dataset is intended for demonstrating the main functions of AISanalyze, including travel distance estimation, GPS error correction, vessel characteristic estimation, interpolation and vessel extraction. Original MMSI identifiers and vessel names have been replaced with anonymized values to protect vessel confidentiality.
Example subset extracted from AIS observations.
Detects and corrects GPS errors and delayed AIS messages that generate unrealistic vessel speeds, travelled distances, and travel times. Note: For consecutive GPS errors, only the first point is removed to avoid overcorrection.
AIScorrect_speed( ais_data, crs_meters = 3035, threshold_speed_to_correct = 100, threshold_speed_to_correct_function = NULL, nb_cores = 1, outfile = tempfile() )AIScorrect_speed( ais_data, crs_meters = 3035, threshold_speed_to_correct = 100, threshold_speed_to_correct_function = NULL, nb_cores = 1, outfile = tempfile() )
ais_data |
AIS data frame containing |
crs_meters |
CRS (metres) used to calculate distances
in the study area (defaults to EPSG:3035, Europe).
Tip: use |
threshold_speed_to_correct |
Speed threshold (km/h) above which observations are corrected. |
threshold_speed_to_correct_function |
a function to estimate vessel-specific
speed thresholds. The function can use all columns of ais_data as argument
(such as |
nb_cores |
Number of CPU cores used. |
outfile |
File used to save logs. |
When threshold_speed_to_correct_function is set to NULL, a vessel-specific
speed threshold is estimated from the observed vessel speed_kmh. The
threshold is calculated as:
where represents vessel speeds greater than 1 km/h, and
represents vessel speeds between 1 km/h and the
75th percentile. The equation is designed to capture the typical
travelling speed of the vessel while accounting for variation in its
observed travelling speeds.
The input data with corrected travel metrics and the following columns:
speed_kmh_corrected: Whether the speed was corrected.
time_travelled: Travel time (s).
distance_travelled: Travelled distance (m).
speed_kmh: Vessel speed (km/h).
data("ais") # use only a sample for the example: ais <- ais[ais$mmsi %in% ais$mmsi[1:5], ] # Define the Unix time (seconds since 1970-01-01) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: ais <- AIStravel(ais_data = ais, crs_meters = 3035) # Correct speed: out <- AIScorrect_speed(ais_data = ais, crs_meters = 3035)data("ais") # use only a sample for the example: ais <- ais[ais$mmsi %in% ais$mmsi[1:5], ] # Define the Unix time (seconds since 1970-01-01) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: ais <- AIStravel(ais_data = ais, crs_meters = 3035) # Correct speed: out <- AIScorrect_speed(ais_data = ais, crs_meters = 3035)
Returns either (depending on return_all_vessel_locations):
the position of each vessel at the time closest to the target timestamps.
or all vessel positions within a specified time window.
AISextract( ais_data, data, crs_meters = 3035, return_all_vessel_locations = TRUE, search_into_radius_m = 50000, search_shape = "circle", interval_time_before = 5 * 60, interval_time_after = 5 * 60, nb_cores = 1, outfile = tempfile() )AISextract( ais_data, data, crs_meters = 3035, return_all_vessel_locations = TRUE, search_into_radius_m = 50000, search_shape = "circle", interval_time_before = 5 * 60, interval_time_after = 5 * 60, nb_cores = 1, outfile = tempfile() )
ais_data |
AIS data frame containing |
data |
Data frame containing |
crs_meters |
CRS (metres) used to calculate distances
in the study area (defaults to EPSG:3035, Europe).
Tip: use |
return_all_vessel_locations |
Logical. If |
search_into_radius_m |
Search radius (m). |
search_shape |
|
interval_time_before |
Time window (s) before each |
interval_time_after |
Time window (s) after each |
nb_cores |
Number of CPU cores used. |
outfile |
File used to save logs. |
data joined with matching AIS positions. Rows are duplicated when
several vessel positions match a target location and time. If no vessel is
found, AIS columns (including mmsi) are filled with NA. The output also
includes distance_vessel_to_location_m, the distance (m) between the
target location and vessel positions.
data("ais") data("point_to_extract") # use only a sample for the example: ais <- ais[20000:30000, ] # Define the Unix time (seconds since 1970-01-01) point_to_extract$timestamp <- as.numeric(lubridate::ymd_hm(point_to_extract$datetime)) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, speed, and interpolate AIS data: ais <- AIStravel(ais, crs_meters = 3035) # Extract all vessel positions within the target time interval and radius: out <- AISextract(ais_data = ais, data = point_to_extract, crs_meters = 3035, return_all_vessel_locations = TRUE, # set FALSE to only # extract the vessel position closest in time to the # target timestamps. search_into_radius_m = 50000, interval_time_before = 5 * 60, interval_time_after = 5 * 60)data("ais") data("point_to_extract") # use only a sample for the example: ais <- ais[20000:30000, ] # Define the Unix time (seconds since 1970-01-01) point_to_extract$timestamp <- as.numeric(lubridate::ymd_hm(point_to_extract$datetime)) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, speed, and interpolate AIS data: ais <- AIStravel(ais, crs_meters = 3035) # Extract all vessel positions within the target time interval and radius: out <- AISextract(ais_data = ais, data = point_to_extract, crs_meters = 3035, return_all_vessel_locations = TRUE, # set FALSE to only # extract the vessel position closest in time to the # target timestamps. search_into_radius_m = 50000, interval_time_before = 5 * 60, interval_time_after = 5 * 60)
Stations and aircraft are identified from speed, distance and time only. Other criteria (e.g. MMSIs with fewer than 9 digits) are not considered.
AISidentify_stations_aircraft(ais_data, crs_meters = 3035)AISidentify_stations_aircraft(ais_data, crs_meters = 3035)
ais_data |
AIS data frame containing |
crs_meters |
CRS (metres) used to calculate distances
in the study area (defaults to EPSG:3035, Europe).
Tip: use |
The input AIS data with the following additional columns:
station: Whether the MMSI is classified as a base station.
high_speed: Whether the MMSI is classified as a high-speed craft.
n_point_mmsi_initial_data: Number of valid AIS positions for the MMSI.
id_mmsi_point_initial: Sequential identifier of each AIS position.
data("ais") # Define the Unix time (seconds since 1970-01-01) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: ais <- AIStravel(ais_data = ais, crs_meters = 3035) # Identify stations and aircrafts: out <- AISidentify_stations_aircraft(ais_data = ais, crs_meters = 3035)data("ais") # Define the Unix time (seconds since 1970-01-01) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: ais <- AIStravel(ais_data = ais, crs_meters = 3035) # Identify stations and aircrafts: out <- AISidentify_stations_aircraft(ais_data = ais, crs_meters = 3035)
Estimates the most likely vessel characteristics for each mmsi from AIS
messages, including ship type, length, width, draught, IMO number, and
vessel name. Estimates are based on the most frequent values, giving greater
weight to records with more complete information.
Warnings are printed if any value of length, draught, width, or IMO cannot
be converted to numeric (and is therefore set to NA) or any value of
ship type or name cannot be converted to character (set to NA).
AISinfos( ais_data, threshold_length = 475, threshold_draught = 30, threshold_width = 75, weight_complete_data = 10 )AISinfos( ais_data, threshold_length = 475, threshold_draught = 30, threshold_width = 75, weight_complete_data = 10 )
ais_data |
AIS data frame containing the columns |
threshold_length |
Maximum valid vessel length (m). Larger values are
set to |
threshold_draught |
Maximum valid draught (m). Larger values are set
to |
threshold_width |
Maximum valid vessel width (m). Larger values are
set to |
weight_complete_data |
Weight assigned to records containing both vessel length and ship type. |
A list containing:
estimated_values: Estimated vessel characteristics for each mmsi.
summary: Summary statistics for each mmsi, including:
Number of AIS positions.
Number of non-missing values for length, shiptype, width,
draught, imo, and name.
All valid values observed for each characteristic.
The most likely value for each characteristic.
data("ais") out <- AISinfos(ais_data = ais)data("ais") out <- AISinfos(ais_data = ais)
Interpolates vessel positions either: (depending on type_interpolation)
to ensure time intervals do not exceed a specified maximum
(= maximum_gap_seconds).
at user-defined timestamps (= exact_timestamp). Interpolation
can optionally be restricted to specific regions to reduce computation
time with locations_of_interest and radius arguments.
AISinterpolate( ais_data, type_interpolation, maximum_gap_seconds, exact_timestamp = list(timestamp_to_interpolate, locations_of_interest, radius), crs_meters = 3035, nb_cores = 1, outfile = tempfile() )AISinterpolate( ais_data, type_interpolation, maximum_gap_seconds, exact_timestamp = list(timestamp_to_interpolate, locations_of_interest, radius), crs_meters = 3035, nb_cores = 1, outfile = tempfile() )
ais_data |
AIS data frame containing |
type_interpolation |
Interpolation mode: |
maximum_gap_seconds |
used when
|
exact_timestamp |
List used when
|
crs_meters |
CRS (metres) used to calculate distances
in the study area (defaults to EPSG:3035, Europe).
Tip: use |
nb_cores |
Number of CPU cores used. |
outfile |
File used to save logs. |
The interpolated AIS data with an additional column:
interpolated: Whether the position was interpolated.
data("ais") data("point_to_extract") # use only a sample for the example: ais <- ais[20000:30000, ] # Define the Unix time (seconds since 1970-01-01) point_to_extract$timestamp <- as.numeric(lubridate::ymd_hm(point_to_extract$datetime)) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: ais <- AIStravel(ais_data = ais, crs_meters = 3035) # Interpolate all AIS signals further than > 120 seconds: out <- AISinterpolate(ais_data = ais, type_interpolation = "maximum_gap_seconds", maximum_gap_seconds = 120, ## Alternatively, you can ## interpolate at target timestamps with: # exact_timestamp = list( # timestamp_to_interpolate = point_to_extract$timestamp, # locations_of_interest = data.frame(lon = point_to_extract$lon, # lat = point_to_extract$lat), # radius = 200000), crs_meters = 3035)data("ais") data("point_to_extract") # use only a sample for the example: ais <- ais[20000:30000, ] # Define the Unix time (seconds since 1970-01-01) point_to_extract$timestamp <- as.numeric(lubridate::ymd_hm(point_to_extract$datetime)) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: ais <- AIStravel(ais_data = ais, crs_meters = 3035) # Interpolate all AIS signals further than > 120 seconds: out <- AISinterpolate(ais_data = ais, type_interpolation = "maximum_gap_seconds", maximum_gap_seconds = 120, ## Alternatively, you can ## interpolate at target timestamps with: # exact_timestamp = list( # timestamp_to_interpolate = point_to_extract$timestamp, # locations_of_interest = data.frame(lon = point_to_extract$lon, # lat = point_to_extract$lat), # radius = 200000), crs_meters = 3035)
Calculates the distance travelled (m), travel time (s), and speed (km/h)
between consecutive AIS positions for each vessel (mmsi).
AIStravel(ais_data, crs_meters = 3035, nb_cores = 1, outfile = tempfile())AIStravel(ais_data, crs_meters = 3035, nb_cores = 1, outfile = tempfile())
ais_data |
AIS data frame containing |
crs_meters |
CRS (metres) used to calculate distances
in the study area (defaults to EPSG:3035, Europe).
Tip: use |
nb_cores |
Number of CPU cores used. |
outfile |
File used to save logs. |
The input AIS data with the following additional columns:
time_travelled: Travel time (s) since the previous AIS position.
distance_travelled: Distance travelled (m) since the previous AIS position.
speed_kmh: Vessel speed (km/h).
X, Y: coordinates in crs_meters.
data("ais") # Define the Unix time (seconds since 1970-01-01) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: out <- AIStravel(ais_data = ais, crs_meters = 3035)data("ais") # Define the Unix time (seconds since 1970-01-01) ais$timestamp <- as.numeric(lubridate::ymd_hms(ais$datetime)) # calculate the travelled distance, time, and speed: out <- AIStravel(ais_data = ais, crs_meters = 3035)
Example locations and timestamps used to demonstrate
AISextract() and interpolation at exact timestamps with
AISinterpolate(). Each row defines a target location and time for which
nearby vessel positions can be extracted or interpolated.
A data frame with the following variables:
Unique identifier of the target location.
Longitude and latitude (WGS84).
Target date and time (UTC).
AISextract(), AISinterpolate()