Skip to contents

Calculates the distance travelled (m), travel time (s), and speed (km/h) between consecutive AIS positions for each vessel (mmsi).

Usage

AIStravel(ais_data, crs_meters = 3035, nb_cores = 1, outfile = tempfile())

Arguments

ais_data

AIS data frame containing timestamp, lon, lat, and mmsi. timestamp must be Unix time (seconds since 1970-01-01), while lon and lat must be numeric. Another vessel identifier may be used if the column is named mmsi.

crs_meters

CRS (metres) used to calculate distances in the study area (defaults to EPSG:3035, Europe). Tip: use suggest_crs function (crsuggest package) to find a suitable CRS for your study area.

nb_cores

Number of CPU cores used.

outfile

File used to save logs.

Value

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.

Examples

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)