et_projection.Rd
This function provides a convienant wrapper to
destPoint
et_projection(x, ..., method = "GC") # S3 method for data.frame et_projection(.data, latitude, longitude, bearing, distance, method = "GC") # S3 method for numeric et_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.
# basic use et_projection(39.86167, -104.6732, 90, 15)#> latitude longitude #> 1: 39.86121 -104.3475et_projection(39.86167, -104.6732, 86:90, 1:15)#> latitude longitude #> 1: 39.86283 -104.6515 #> 2: 39.86341 -104.6298 #> 3: 39.86340 -104.6081 #> 4: 39.86280 -104.5864 #> 5: 39.86162 -104.5646 #> 6: 39.86857 -104.5432 #> 7: 39.86768 -104.5214 #> 8: 39.86619 -104.4996 #> 9: 39.86412 -104.4778 #> 10: 39.86147 -104.4561 #> 11: 39.87421 -104.4349 #> 12: 39.87185 -104.4130 #> 13: 39.86889 -104.3911 #> 14: 39.86535 -104.3693 #> 15: 39.86121 -104.3475# 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"):=et_projection(latitude, longitude, 90, 15)]#> airport latitude longitude platitude plongitude #> 1: ATL 33.63670 -84.42786 33.63634 -84.12762 #> 2: DEN 39.86167 -104.67317 39.86121 -104.34752 #> 3: ORD 41.97933 -87.90739 41.97884 -87.57113 #> 4: SEA 47.44989 -122.31178 47.44930 -121.94213# use with magrittr library(magrittr) apts %>% et_projection(latitude, longitude, 90, 15)#> airport latitude longitude platitude plongitude end_latitude end_longitude #> 1: ATL 33.63670 -84.42786 33.63634 -84.12762 33.63634 -84.12762 #> 2: DEN 39.86167 -104.67317 39.86121 -104.34752 39.86121 -104.34752 #> 3: ORD 41.97933 -87.90739 41.97884 -87.57113 41.97884 -87.57113 #> 4: SEA 47.44989 -122.31178 47.44930 -121.94213 47.44930 -121.94213# columns as strings lat_col <- names(apts)[2] apts %>% et_projection(lat_col, "longitude", 90, 15)#> Error in eval(val): object 'lat_col' not found# 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 %>% et_projection(lat, lon, heading, tracks$ground_speed*time_step)#> Error in eval(val): object 'tracks' not found