[R-sig-Geo] zero distance in spDistsN1

Wouter Buytaert wouter at paramo.be
Wed Feb 10 23:38:24 CET 2010


Hi list,

I found some strange behaviour in the latest version of spDistsN1:

> spDistsN1(cbind(c(1,2,3,4),c(0,0,0,0)), c(0,0), longlat = TRUE)
[1] 0 0 0 0
> spDistsN1(cbind(c(1,2,3,4),c(0,0,0,0)), c(0,0), longlat = FALSE)
[1] 1 2 3 4

It seems that for longlat=TRUE, zeros are returned whenever the latitude 
values are equal, because:

> spDistsN1(cbind(c(1,2,3,4),c(0.0001,0,0,0)), c(0,0), longlat = TRUE)
[1] 111.3195   0.0000   0.0000   0.0000

Here is some info on the package version:

> packageDescription("sp")
Package: sp
Version: 0.9-57
[...]
Built: R 2.10.1; x86_64-pc-linux-gnu; 2010-01-29 17:10:42 UTC; unix

but I also get it under windows and mac. Version 0.9-56 under mac worked 
fine:

> spDistsN1(cbind(c(1,2,3,4),c(0,0,0,0)), c(0,0), longlat = TRUE)
[1] 111.3195 222.6390 333.9585 445.2780



cheers
wouter



More information about the R-sig-Geo mailing list