Skip to content
Back to formatted view

Raw Message

Message-ID: <alpine.DEB.2.00.1002101854460.2350@cotopaxi>
Date: 2010-02-10T22:38:24Z
From: wouter buytaert
Subject: zero distance in spDistsN1

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