I am using the function distVincentyEllipsoid() from the geosphere package to calculate distances between the world's ports. This function takes as input the longitude and latitude of two places and gives the distance in meters as output. It appears to work well generally, but in some cases it's been giving me NAs for no discernible reason. I was wondering whether anyone was aware of a bug (there is no documentation online I could find that addresses this issue), or could perhaps point me to what I'm doing wrong. What's strange is that it appears to affect only specific pairs – eg. f(a,b) and f(b,a) will give NA, but f(a,c) and f(b,c) will not.
Eg. Whangarei, New Zealand (Lon:174.35 Lat:-35.76) to Gibraltar, Gibraltar (Lon: -5.35 Lat:36.13):
distVincentyEllipsoid(c(174.35,-35.76),c(-5.35,36.13))
> NA
...but:
Valetta, Malta (Lon:14.51 Lat:35.89) to Gibraltar, Gibraltar (Lon: -5.35 Lat:36.13):
distVincentyEllipsoid(c(14.51,35.89),c(-5.35,36.13))
> 1787499
...and:
Whangarei, New Zealand (Lon:174.35 Lat:-35.76) to Valetta, Malta (Lon:14.51 Lat:35.89):
distVincentyEllipsoid(c(174.35,-35.76),c(14.51,35.89))
> 18207301
(Both of these outputs are correct according to Google Maps - note these values are in metres.)
Any help would be greatly appreciated.
EDIT: Problem solved – Vincenty's distance method fails for near-antipodal points.