radiusOfGyrationDT | R Documentation |
Calculates the time-weighted radius of Gyration provided a data.table containing latitude, longitude and a timestamp. This is the root-mean-square time-weighted average of all locations. Weighting by time is provided to adjust for unequal frequency of data collection.
radiusOfGyrationDT(lat_col, lon_col, timestamp, dist_measure = "geodesic")
lat_col |
Time-ordered vector of latitudes |
lon_col |
Time-ordered vector of longitudes |
timestamp |
Timestamps associated with the latitude/longitude pairs |
dist_measure |
Passed through to geodist::geodist_vec, One of "haversine" "vincenty", "geodesic", or "cheap" specifying desired method of geodesic distance calculation. |
Time-weighted RoG is defined as
sqrt(1/sum(w_j) * sum(w_j * dist(|mean_lon, mean_lat|, |lon_j, lat_j|)^2))
Where
mean_lon = sum(w_j * lon_j)/sum(w_j) and mean_lat = sum(w_j * lat_j)/sum(w_j)
And the weighting element w_j represents half the time interval during which a location was recorded
w_j = (t_j+1 - t_j-1)/2
Time-weighted radius of gyration
# Inside a data.table dt <- data.table::data.table( lat = c(1, 1, 1, 1, 1), lon = c(1, 1.5, 4, 1.5, 2), timestamp = c(100, 200, 300, 600, 900) ) dt[, radiusOfGyrationDT(lat, lon, timestamp)] # As vectors radiusOfGyrationDT( c(1, 1, 1, 1, 1), c(1, 1.5, 4, 1.5, 2), c(100, 200, 300, 600, 900) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.