[R-sig-Geo] near neighbor using decimal degree or projected coord system

Gabriele Cozzi gab.cozzi at gmail.com
Mon Apr 23 10:16:53 CEST 2012


Dear all,
I am using knearneigh dnearneigh {spdep} to set neighbor distances for a 
SAR analysis. I tried to used projected coord systems (UTM 34S, units: 
meters) and geographic coordinate systems (in decimal degrees) for what 
I thought should give the same result but I am somehow getting different 
results which confuses me a bit. I guess sometimes double checking is 
not a good idea ;-)

I set:
coord<- as.matrix(cbind(X,Y))      # where X and Y is respectively in 
the projected and in the geographic format.

k_nb<-knn2nb(knearneigh(coord, k=1, longlat= LOGIC, RANN=TRUE))     # 
where LOGIC=FALSE when X and Y are in the projected format and
                                                                                                                                          LOGIC=TRUE when X and Y are in the decimal degrees format

distance<-unlist(nbdists(k_nb, coords))
summary(distance)            # to get the minimal distance to ensure all 
locations have at least one neighbor.

the summary output is as follow:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   14.87  257.30  398.10  415.30  550.10 1429.00    # where I use the 
projected coord system

    Min.             1st Qu.         Median      Mean           3rd Qu. 
           Max.
0.0001414 0.0023600 0.0036880 0.0038520  0.0051070  0.0135300   # where 
I use the decimal degree coord system

I have to slight problems with these results and I would appreciate if 
someone could help

1) I thought that setting longlat=TRUE using decimal degrees would give 
distances between neighbors in kilometers. However here I am two orders 
of magnitude wrong. I know I could simply using longlat=FALSE that seems 
to give the correct distances but I was nonetheless keen to understand 
why there are differences.

2)  I see there are some slight differences in the distances. e.g. max = 
1429 vs. max = 1353 (*10e-5). What type of transformation is used to 
pass from decimal degrees to euclidean distances?

Any comment would be appreciated.

Best,
Gabriele




-- 

============================================================

Gabriele Cozzi

Institute of Evolutionary Biology and Environmental Studies
Zurich University
Winterthurerstr. 190
8057 Zurich - Switzerland
E-mail: gabriele.cozzi at uzh.ch
Phone: ++41(0)44 6356116
Fax: ++41(0)44 6355711
http://www.ieu.uzh.ch
http://african-carnivores.com

Botswana Predator Conservation Trust
Private Bag 13
Maun - Botswana
E-mail: gab.cozzi at gmail.com
Mobile: +26774259312
http://www.bpctrust.org



More information about the R-sig-Geo mailing list