compute_projection: compute location of coordinates after great circle projection

Description Usage Arguments Value Examples

Description

This function provides a convienant wrapper to destPoint

Usage

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")

Arguments

x

An object used to determine which implementation to use

...

It's an S3 thing. You wouldn't understand.

method

Either "GC" [default] or "rhumb". Used to declare either a great circle calculation or rhumb line calculation

.data

An object that inherits from data.frame. In general this will be on of data.frame, data.table, or tbl_df

latitude

Either a numeric vector of latitudes [degrees] or the column of .data which contains latitudes. This maybe quoted or unquoted; see examples.

longitude

Either a numeric vector of longitudes [degrees] corresponding with latitude or the column of .data which contains longitudes. This maybe quoted or unquoted; see examples.

bearing

Either a numeric vector of bearings [degrees] or the column of .data which contains bearings/headings. This maybe quoted or unquoted see examples.

distance

Either a numeric vector of projection distance [nautical miles] or the column of .data which contains projection distances. This maybe quoted or unquoted see examples.

output_type

string in c("matrix", "data.table", "data.frame", "list")

Value

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.

Examples

 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)

mitre/earthtools documentation built on May 21, 2019, 1:19 p.m.