我正在尝试测量雏鸟从原来的巢址移动到他们第二年建立的领地的距离。我想使用 spatstat 包来执行此操作,但我在输出的某些功能(例如,nncross、nndist、crossdist)时遇到了问题。这是我的代码的样子,数据在这里:https ://sites.google.com/site/datastackoverflow/shapefiles
library(raster)
library(spatstat)
library(maptools)
# read in shapefile with nest locations (UTMs) and convert to ppp format:
nests <- readShapeSpatial("nest_locs.shp")
X<-as.ppp(nests)
X
# read in shapefile with juvenile locations (UTMs) and convert to ppp format:
juvs <- readShapeSpatial("juv_locs.shp")
Y<-as.ppp(juvs)
Y
# calculate the distance between nest points and juveniles:
N<-nncross(X,Y)
N
# another option
crossdist(X, Y)
结果如下所示:
> crossdist(X, Y)
[,1] [,2]
[1,] 2756.546 1994.002
[2,] 3831.429 3466.360
是否可以保留点 ID,在这种情况下是 nestID 和相应的birdID,而不是行号和列号?