[R-sig-Geo] zero distance in spDistsN1

Roger Bivand Roger.Bivand at nhh.no
Thu Feb 11 08:38:43 CET 2010


On Wed, 10 Feb 2010, Wouter Buytaert wrote:

>
> 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:

Thanks for an accurate and easily reproducible report. Fixed sp 0.9-59 
submitted to CRAN, committed to sourceforge CVS on r-spatial.

The reason was the omission of an abs() around a new test introduced 14 
January 2010 to return 0.0 when longitudes were 360 degrees apart (so 
effectively but not numerically identical) for identical latitudes. Output 
since that time, for identical latitudes only, may bave been affected.

Roger

>
>> 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list