Description Usage Arguments Value Examples
This function provides a convienant wrapper to
destPoint
1 2 3 4 5 6 7 8 9 | compute_projection(x, ..., method = "GC")
## S3 method for class 'data.frame'
compute_projection(.data, latitude, longitude,
bearing, distance, method = "GC")
## S3 method for class 'numeric'
compute_projection(latitude, longitude, bearing,
distance, output_type = "data.table", method = "GC")
|
x |
An object used to determine which implementation to use |
... |
It's an S3 thing. You wouldn't understand. |
method |
Either |
.data |
An object that inherits from |
latitude |
Either a numeric vector of latitudes [degrees] or the column
of |
longitude |
Either a numeric vector of longitudes [degrees]
corresponding with latitude or the column of |
bearing |
Either a numeric vector of bearings [degrees] or the column of
|
distance |
Either a numeric vector of projection distance [nautical
miles] or the column of |
output_type |
string in |
If .data
is supplied, an object of the same type and with the
same columns as .data
plus two more, end_latitude
and
end_longitude
. Otherwise, an object of type determined by
output_type which will generally have two columns, latitude and longitude.
If the input coordinates have length 1, then a named numeric vector is
returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # basic use
compute_projection(39.86167, -104.6732, 90, 15)
compute_projection(39.86167, -104.6732, 86:90, 1:15)
# use inside a data.table
library(data.table)
apts <- data.table(airport=c("ATL", "DEN", "ORD", "SEA"),
latitude=c(33.63670, 39.86167, 41.97933, 47.44989),
longitude=c(-84.42786, -104.67317, -87.90739, -122.31178))
apts[, c("platitude", "plongitude"):=compute_projection(latitude, longitude, 90, 15)]
# use with magrittr
library(magrittr)
apts %>% compute_projection(latitude, longitude, 90, 15)
# columns as strings
lat_col <- names(apts)[2]
apts %>% compute_projection(lat_col, "longitude", 90, 15)
# predict next position
tracks <- data.frame(id = c("a","b","c"),
lat = 0,
lon = 0,
heading = 30,
ground_speed = seq(300,360, 30))
time_step <- 1/60 #one minute
tracks %>% compute_projection(lat, lon, heading, tracks$ground_speed*time_step)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.