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 withlocations_of_interestandradiusarguments.
Arguments
- ais_data
AIS data frame containing
timestamp,lon,lat, andmmsi.timestampmust be Unix time (seconds since 1970-01-01), whilelonandlatmust be numeric.- type_interpolation
Interpolation mode:
"maximum_gap_seconds"or"exact_timestamp".- maximum_gap_seconds
used when
type_interpolation = "maximum_gap_seconds": threshold above which AIS signals are interpolated.- exact_timestamp
List used when
type_interpolation = "exact_timestamp", containing:timestamp_to_interpolatelocations_of_interest: (optional) data frame withlonandlatcolumns corresponding to eachtimestamp_to_interpolateradius: (optional) a search radius (m) around target locations
- crs_meters
CRS (metres) used to calculate distances in the study area (defaults to EPSG:3035, Europe). Tip: use
suggest_crsfunction (crsuggestpackage) to find a suitable CRS for your study area.- nb_cores
Number of CPU cores used.
- outfile
File used to save logs.
Value
The interpolated AIS data with an additional column:
interpolated: Whether the position was interpolated.
Examples
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)