|
From: | Byerly, Mike M (DFG) |
Subject: | modulo-360 issue with compass heading data |
Date: | Wed, 08 Oct 2014 22:41:09 +0000 |
Hello, I’ve been searching for R functions to address an problem and have ended up using some functions in the Signal package, but I still haven’t arrived at my solution. I have a dataset of tracking data from a vehicle that includes time in
seconds past midnight and heading in degrees. The data were collected at infrequent intervals and I would like to interpolate it to 1-second intervals. Below is some to code to illustrate a very small example. My issue arises when the compass heading data
swings though 360 degrees. I’m using the unwrap() function to deal with that. I’m then interpolating the data using the interp1() function. Providing I’m doing this correctly, which may not be so, I haven’t found a way to convert my heading data back (e.g.
unwraping it). sec <- c(61290,61305,61320,61335) # vector of time in seconds past midnight deg <- c(345,353,20,8) # vector of heading data h <- data.frame(sec,deg) h$uw <- unwrap(h$deg*pi/180) d.int <- interp1(h$sec, h$uw, min(h$sec):max(h$sec), 'linear', extrap = FALSE) s.int <- min(h$sec):max(h$sec) h.int <- data.frame(s.int,h.int) h.int Thanks in advance, Mike |
[Prev in Thread] | Current Thread | [Next in Thread] |