I am trying to use the distVincentyEllipsoid function in the geosphere package in R to calculate the distance between different points in my data frame, following the exampl
I was just having the same issue. Check to see if you input the data as c(LONG, LAT). I had made the mistake of using the more common format of c(LAT, LONG).
Having the same issue, solved with as.numeric :
args <- commandArgs(trailingOnly=TRUE)
Lieu1 <- c(args[1],args[2])
Lieu2 <- c(args[3],args[4])
Lieu1 <- as.numeric(Lieu1)
Lieu2 <- as.numeric(Lieu2)
library(geosphere)
distVincentyEllipsoid(Lieu1,Lieu2)/1000
I would also add that you should check for NAs. I geocoded a set of zip codes to coordinates and since some of the zips were out of date (at least that's what I think happened), they failed to generate coordinates.
If you run:
range(p1[2])
and get
NA NA
then that's a pretty go indication.