4. Tracks

Introduction

Points on great circles, etc.

Points on great circles

Points on a great circle are returned by the function ‘greatCircle’, using two points on the great circle to define it, and an additional argument to indicate how many points should be returned. You can also use greatCircleBearing, and provide starting points and bearing as arguments. gcIntermediate only returns points on the great circle that are on the track of shortest distance between the two points defining the great circle; and midPoint computes the point half-way between the two points. You can use onGreatCircle to test whether a point is on a great circle between two other points.

LA <- c(-118.40, 33.95)
NY <- c(-73.78,  40.63)
data(wrld)
## Warning in data(wrld): data set 'wrld' not found
plot(wrld, type='l')
## Error in plot(wrld, type = "l"): object 'wrld' not found
gc <- greatCircle(LA, NY)
## Error in eval(expr, envir, enclos): could not find function "greatCircle"
lines(gc, lwd=2, col='blue')
## Error in as.double(y): cannot coerce type 'closure' to vector of type 'double'
gci <- gcIntermediate(LA, NY)
## Error in eval(expr, envir, enclos): could not find function "gcIntermediate"
lines(gci, lwd=4, col='green')
## Error in lines(gci, lwd = 4, col = "green"): object 'gci' not found
points(rbind(LA, NY), col='red', pch=20, cex=2)
## Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
mp <- midPoint(LA, NY)
## Error in eval(expr, envir, enclos): could not find function "midPoint"
onGreatCircle(LA,NY, rbind(mp,c(0,0)))
## Error in eval(expr, envir, enclos): could not find function "onGreatCircle"
points(mp, pch='*', cex=3, col='orange')
## Error in points(mp, pch = "*", cex = 3, col = "orange"): object 'mp' not found
greatCircleBearing(LA, brng=270, n=10)
## Error in eval(expr, envir, enclos): could not find function "greatCircleBearing"

Maximum latitude on a great circle

You can use the functions illustrated below to find out what the maximum latitude is that a great circle will reach; at what latitude it crosses a specified longitude; or at what longitude it crosses a specified latitude. From the map below it appears that Clairaut’s formula, used in gcMaxLat is not very accurate. Through optimization with function greatCircle, a more accurate value was found. The southern-most point is the antipode (a point at the opposite end of the world) of the northern-most point.

ml <- gcMaxLat(LA, NY)
## Error in eval(expr, envir, enclos): could not find function "gcMaxLat"
lat0 <- gcLat(LA, NY, lon=0)
## Error in eval(expr, envir, enclos): could not find function "gcLat"
lon0 <- gcLon(LA, NY, lat=0)
## Error in eval(expr, envir, enclos): could not find function "gcLon"
plot(wrld, type='l')
## Error in plot(wrld, type = "l"): object 'wrld' not found
lines(gc, lwd=2, col='blue')
## Error in as.double(y): cannot coerce type 'closure' to vector of type 'double'
points(ml, col='red', pch=20, cex=2)
## Error in points(ml, col = "red", pch = 20, cex = 2): object 'ml' not found
points(cbind(0, lat0), pch=20, cex=2, col='yellow')
## Error in cbind(0, lat0): object 'lat0' not found
points(t(rbind(lon0, 0)), pch=20, cex=2, col='green' )
## Error in rbind(lon0, 0): object 'lon0' not found

f <- function(lon){gcLat(LA, NY, lon)}
opt <- optimize(f, interval=c(-180, 180), maximum=TRUE)
## Error in f(arg, ...): could not find function "gcLat"
points(opt$maximum, opt$objective, pch=20, cex=2, col='dark green' )
## Error in points(opt$maximum, opt$objective, pch = 20, cex = 2, col = "dark green"): object 'opt' not found
anti <- antipode(c(opt$maximum, opt$objective))
## Error in eval(expr, envir, enclos): could not find function "antipode"
points(anti, pch=20, cex=2, col='dark blue' )
## Error in points(anti, pch = 20, cex = 2, col = "dark blue"): object 'anti' not found

Great circle intersections

Points of intersection of two great circles can be computed in two ways. We use a second great circle that connects San Francisco with Amsterdam. We first compute where they cross by defining the great circles using two points on it (gcIntersect). After that, we compute the same points using a start point and initial bearing (gcIntersectBearing). The two points where the great circles cross are antipodes. Antipodes are connected with an infinite number of great circles.

SF <- c(-122.44, 37.74)
AM <- c(4.75, 52.31)
gc2 <- greatCircle(AM, SF)
## Error in eval(expr, envir, enclos): could not find function "greatCircle"
plot(wrld, type='l')
## Error in plot(wrld, type = "l"): object 'wrld' not found
lines(gc, lwd=2, col='blue')
## Error in as.double(y): cannot coerce type 'closure' to vector of type 'double'
lines(gc2, lwd=2, col='green')
## Error in lines(gc2, lwd = 2, col = "green"): object 'gc2' not found
int <- gcIntersect(LA, NY, SF, AM)
## Error in eval(expr, envir, enclos): could not find function "gcIntersect"
int
## Error in eval(expr, envir, enclos): object 'int' not found
antipodal(int[,1:2], int[,3:4])
## Error in eval(expr, envir, enclos): could not find function "antipodal"
points(rbind(int[,1:2], int[,3:4]), col='red', pch=20, cex=2)
## Error in rbind(int[, 1:2], int[, 3:4]): object 'int' not found
bearing1 <- bearing(LA, NY)
## Error in eval(expr, envir, enclos): could not find function "bearing"
bearing2 <- bearing(SF, AM)
## Error in eval(expr, envir, enclos): could not find function "bearing"
bearing1
## Error in eval(expr, envir, enclos): object 'bearing1' not found
bearing2
## Error in eval(expr, envir, enclos): object 'bearing2' not found
gcIntersectBearing(LA, bearing1, SF, bearing2)
## Error in eval(expr, envir, enclos): could not find function "gcIntersectBearing"