dtMidpoint: dt midpoint

Description Usage Arguments Value Examples

Description

Finds the half-way point along the great circle path between two points

Usage

1
dtMidpoint(latFrom, lonFrom, latTo, lonTo)

Arguments

latFrom

latitude from

lonFrom

longitude from

latTo

latitude to

lonTo

longitude to

Value

list of the latitude & longitude coordinates at the midpoint along the line

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
dtMidpoint(0,0,0,52)

dtMidpoint(25, 0, -25, 0)

dtMidpoint(-37,144,-38,145)

dtMidpoint(25, 0, 35, 0)

n <- 10
set.seed(20170511)
lats <- -90:90
lons <- -180:180
dt <- data.table::data.table(lat1 = sample(lats, size = n, replace = T),
                             lon1 = sample(lons, size = n, replace = T),
                             lat2 = sample(lats, size = n, replace = T),
                             lon2 = sample(lons, size = n, replace = T))

dt[, c("latMid", "lonMid") := dtMidpoint(lat1, lon1, lat2, lon2)]

SymbolixAU/spatialdatatable documentation built on May 6, 2019, 11:20 a.m.