A package to make Spherical Earth computations easier.

Use

This package relies heavily on the geosphere package. The added value here is that it makes it much easier to use the spherical trigonometry functions with data in data.frames.

Key Features

First, some setup data:

Now we can compute distances:

airports %>%
  mutate(dist=et_dist_haversine(latitude, longitude, jfk$latitude, jfk$longitude))
##   airport latitude longitude      dist
## 1     EWR 40.69248 -74.16869 18.028939
## 2     PHL 39.87208 -75.24066 81.271730
## 3     JFK 40.63993 -73.77869  0.000000
## 4     LGA 40.77725 -73.87261  9.281924

Determine the initial/final bearing

##   airport latitude longitude bearing_initial bearing_terminal
## 1     EWR 40.69248 -74.16869        99.90871        100.16285
## 2     PHL 39.87208 -75.24066        55.09815         56.04293
## 3     LGA 40.77725 -73.87261       152.47557        152.53682

And do point projections. Since the projected coordinates have both a latitude and longitude output, this was implemented as an S3 method to support both dplyr and data.table use cases.

The dplyr way:

airports %>%
  et_projection(latitude, longitude, bearing=90, distance=10)
##   airport latitude longitude end_latitude end_longitude
## 1     EWR 40.69248 -74.16869     40.69227     -73.94890
## 2     PHL 39.87208 -75.24066     39.87188     -75.02352
## 3     JFK 40.63993 -73.77869     40.63972     -73.55908
## 4     LGA 40.77725 -73.87261     40.77704     -73.65254

The data.table way:

##    airport latitude longitude end_latitude end_longitude
## 1:     EWR 40.69248 -74.16869     40.69227     -73.94890
## 2:     PHL 39.87208 -75.24066     39.87188     -75.02352
## 3:     JFK 40.63993 -73.77869     40.63972     -73.55908
## 4:     LGA 40.77725 -73.87261     40.77704     -73.65254

See the function documentation for all supported operations.

Installation