impute_coords() imputes missing lon/lat coordinates that occur during GPS lapses.

impute_coords(
  df,
  dt_field = NULL,
  distance_threshold = 100,
  jitter_amount = 5e-05,
  show_lapse_distance = FALSE,
  fill_open_lapses = FALSE,
  speed_threshold = NULL,
  speed_window = NULL,
  open_lapse_length = NULL
)

Arguments

df

data frame containing latitude (lat) and longitude (lon)

dt_field

character; name of datetime field.

distance_threshold

numeric; distance (meters) between the last known coordinates before GPS signal loss and the first known coordinates following signal loss are compared to this value. If the distance exceeds this threshold, coordinates are not imputed. Default = 100 meters.

jitter_amount

numeric; amount of jitter to apply to imputed coords. Default = 0.00005 decimal degrees. See st_jitter.

show_lapse_distance

logical; if TRUE, a column will be added to the output data frame listing the distance between the last and first know coordinates for each lapse in GPS signal. Default = FALSE.

fill_open_lapses

logical; if TRUE,missing coordinates at the beginning and end of the data frame are imputed (i.e. lapses not enclosed by known coordinates). Default = FALSE.

speed_threshold

numeric; criteria to impute open lapses. If the median speed (m/s) of coordinates before or after an open lapse exceeds this threshold, coordinates are not imputed.

speed_window

numeric; number of rows used to calculate speed_threshold.

open_lapse_length

numeric; if the number of rows in an open lapse exceed this threshold, coordinates are not imputed.

Value

a data frame. An additional column is created to indicate whether coordinates were imputed ('imputed_coord').

Examples

if (FALSE) {

impute_coords(df,
  distance_threshold = 100, jitter_amount = 0.00001, fill_open_lapses = FALSE,
  speed_threshold = NULL, speed_window = NULL, open_lapse_length = NULL
)
}