Error in .pointsToMatrix(p1) : latitude > 90

后端 未结 3 1960
情话喂你
情话喂你 2021-01-16 09:46

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

相关标签:
3条回答
  • 2021-01-16 10:02

    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).

    0 讨论(0)
  • 2021-01-16 10:21

    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
    
    0 讨论(0)
  • 2021-01-16 10:24

    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.

    0 讨论(0)
提交回复
热议问题