forestSAS (version 1.0.1)

nnid: Find the id of nearest neighbour for each point.

Description

Find the id of nearest neighbour for each point in a point pattern by specific numbers or circular neighborhood.

Usage

nnid(X, N = NULL, R = NULL, id, exclude = TRUE)

Arguments

X

A marked point pattern (object of class "ppp").

N

Specific number of points in the neighborhood, the value is always assinged 4.

R

Specific circular neighborhood, the value is always assinged 5.

id

Specific identification number of each row in the point pattern.

exclude

Wether including id of core points, if exclude is TRUE the result return the data removed the id of core points, if exclude is FALSE the result return the data with the id of core points.

Value

id of nearest neighbour for each point

Examples

Run this code
# NOT RUN {
library(spatstat)
data(finpines)
#Find the id of the nearest neighbour in a certain numbers and without id
finpines.rmidN4<-nnid(finpines,id=paste("T",1:finpines$n),N=4)
finpines.rmidN4

#Find the id of the nearest neighbour in a certain numbers with id
finpines.idN4<-nnid(finpines,id=paste("T",1:finpines$n),N=4,exclude=FALSE)
finpines.idN4

#Find the id of the nearest neighbour within a certain radius without id
data(tree.ppp)
finpines.rmidR0.5<-nnid(tree.ppp,id=paste("T",1:41),R=0.5)
finpines.rmidR0.5

#Find the id of the nearest neighbour within a certain radius with id
finpines.idR0.5<-nnid(tree.ppp,id=paste("T",1:41),R=0.5,exclude=FALSE)
finpines.idR0.5
# }

Run the code above in your browser using DataCamp Workspace