[R-sig-eco] Spatial Statistics

Isaac Brito Morales isaacbrito83 at yahoo.com
Wed Jul 1 18:25:07 CEST 2009


Dear list members,

I'm working in a spatial analysis field, and i built a code for estimated the nearest distance among two circles. The problem is that this circles have an area and "the real distance" is among the boundaries of this circles. As you can see in the code below, i saw that i corrected this problem but in the last part, and i have to do it in the first part. 

Thank you very much in advance.
Best,

Isaac


  ####### Nearest Neighbours ##########
  
  NearestNeighbours<-function(data,pos){
  require(fields)
  
  d<-data[pos,]
  posiciones<-d[,1:2]
  area<-data[,3]
  D<-rdist(posiciones,posiciones)
  diag(D)<-NA

  out<-NULL

  for(i in 1:nrow(D)){
  index<-which.min(D[i,])[1]
  nn<-d[index,1:2]
  radio1<-sqrt(d[index,3]/pi)
  radio2<-sqrt(d[i,3]/pi)

  focal<-d[i,1:2]
  dd<-as.vector(rdist(focal,nn))
  dd2<-radio1+radio2

  DIST.BORDES<-(dd-dd2)  
  DIFF.AREA<-d[i,3]-d[index,3]

  out<-rbind(out,c(focal,nn,DIST.BORDES,DIFF.AREA,d[i,3],d[index,3]))
  
  }
  out
  
  }




      ____________________________________________________________________________________
¡Obtén la mejor experiencia en la web!
Descarga gratis el nuevo Internet Explorer 8. 
http://downloads.yahoo.com/ieak8/?l=e1



More information about the R-sig-ecology mailing list