#' Centroid triangulation over time
#' @description Smooth triangulation points with centroids
#'
#' @param tri_data data.frame. triangulated points
#' @param time numeric. time in minutes to aggregate triangulation points
#' @param s_time numeric. time in second. How much points in each minute
#' @param method string. either mean or median
#'
#' @return smoothed triangulations
#'
#' @author RadioTracking EU
#'
#' @import foreach
#'
#' @export
centroid <- function(tri_data, time, s_time, method="mean"){
min_time <- min(tri_data$timestamp)
max_time <- max(tri_data$timestamp)
time_seq <- seq(round(min_time, "mins") - 60, round(max_time, "mins") + 60, by = 60*time)
utm <- foreach::foreach(i = time_seq,
.combine = rbind,
.inorder = F) %dopar% {
tmp <- subset(tri_data,timestamp>=i×tamp<i+60*s_time)
zone<-(floor((tmp$pos.X[1] + 180)/6) %% 60) + 1
if(nrow(tmp)>0){
data.frame(timestamp=i,
freq_tag=tmp$freq_tag[1],
pos.utm.X=switch(method,
mean=mean(tmp$pos.utm.X),
median=median(tmp$pos.utm.X)),
pos.utm.Y=switch(method,
mean=mean(tmp$pos.utm.Y),
median=median(tmp$pos.utm.Y)),
utm.zone=zone)
}
}
location_wgs<-utmtowgs(utm$pos.utm.X,utm$pos.utm.Y,utm$utm.zone)
return(cbind(utm,pos=location_wgs))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.