straightPath: Mark Straight Path Segments in GPS Track

View source: R/straightPath.R

straightPathR Documentation

Mark Straight Path Segments in GPS Track


This function attempts to mark portions of a GPS track where a ship is traveling in a straight line by comparing the recent average heading with a longer term average heading. If these are different, then the ship should be turning. Note this currently does not take in to account time, only number of points


straightPath(gps, nSmall = 10, nLarge = 60, thresh = 10, plot = FALSE)



gps data with columns Longitude, Latitude, and UTC (POSIX format). Usually this has been read in from a Pamguard database, in which case columns Heading and Speed will also be used.


number of points to average to get ship's current heading


number of points to average to get ship's longer trend heading


the amount which nSmall and nBig should differ by to call this a turn


logical flag to plot result, gps must also have columns Latitude and Longitude


the original dataframe gps with an added logical column straight indicating which portions are approximately straight


Taiki Sakai


gps <- data.frame(Latitude = c(32, 32.1, 32.2, 32.2, 32.2),
                  Longitude = c(-110, -110.1, -110.2, -110.3, -110.4),
                  UTC = as.POSIXct(c('2000-01-01 00:00:00', '2000-01-01 00:00:10',
                                     '2000-01-01 00:00:20', '2000-01-01 00:00:30',
                                     '2000-01-01 00:00:40')),
                  Heading = c(320, 320, 270, 270, 270),
                  Speed = c(.8, .8, .5, .5, .5))

straightPath(gps, nSmall=1, nLarge=2)

straightPath(gps, nSmall=1, nLarge=4)

PAMmisc documentation built on Dec. 28, 2022, 1:30 a.m.