0

我对 R 非常陌生,正在尝试确定包含约 500k 点的形状文件是否是随机分布的。无论我输入什么参数,我都会收到相同的错误消息。

这是我从一开始就拥有的:

> library(spatstat)

spatstat 1.40-0       (nickname: ‘Do The Maths’) 
For an introduction to spatstat, type ‘beginner’
> as.ppp(area)
marked planar point pattern: 500000 points
Mark variables: 
[1] OBJECTID   Encoded_Ti Time_      Filter     Category   Severity      Action_    Hit_Count  Profile    Encoded_So Source_IP  Source_Por Encoded_De
[14] Dest_IP    Dest_Port  VLAN_Tag   Source_Cou Source_Reg Source_Cit     Source_Lat Source_Lon Dest_Count Dest_Regio Dest_City  Dest_Latit Dest_Longi
window: rectangle = [-159.964, 178.417] x [-46.4, 70.6349] units
Warning message:
some mark values are NA in the point pattern x 
> quadrat.test(area)
Error in UseMethod("quadrat.test") : 
no applicable method for 'quadrat.test' applied to an object of class          "c('SpatialPointsDataFrame', 'SpatialPoints', 'Spatial')"


<bytecode: 0x0000000024e7a660>
<environment: namespace:spatstat>

所以我的下一个尝试是:

> X <- ppp(x, y, c(-159.964, 178.417), c(-46.4, 70.6349))
Warning message:
In ppp(x, y, c(-159.964, 178.417), c(-46.4, 70.6349)) :
data contain duplicated points
> quadrat.test(X)
Error in rectquadrat.countEngine(X$x, X$y, tess$xgrid, tess$ygrid) : 
xbreaks do not span the actual range of x coordinates in data

和我最后的尝试:

> quadrat.test(X, nx = 20, ny = 20)
Error in rectquadrat.countEngine(X$x, X$y, tess$xgrid, tess$ygrid) : 
xbreaks do not span the actual range of x coordinates in data
> quadrat.test(X, nx = 20, ny = 20, xbreaks= NULL, ybreaks = NULL)
Error in rectquadrat.countEngine(X$x, X$y, tess$xgrid, tess$ygrid) : 
xbreaks do not span the actual range of x coordinates in data
> data(X)
Warning message:
In data(X) : data set ‘X’ not found
> quadrat.test(X)
Error in rectquadrat.countEngine(X$x, X$y, tess$xgrid, tess$ygrid) : 
xbreaks do not span the actual range of x coordinates in data
> quadrat.test(X, 10)
Error in rectquadrat.countEngine(X$x, X$y, tess$xgrid, tess$ygrid) : 
xbreaks do not span the actual range of x coordinates in data

就像我说的,我对此很陌生,只有业余 python 经验,但我是一名研究生,需要将此功能用于项目。任何帮助将不胜感激。

干杯

4

1 回答 1

0

您应该知道 R(几乎)永远不会改变您的输入变量,因此您需要为您的命令分配一个输出并从那里开始工作。具体来说,如果area是一个可以转换为ppp对象的变量,as.ppp您应该为结果命名:

X <- as.ppp(area)

然后您可以将quadratcountorquadrat.test函数应用于新创建的ppp对象:

quadratcount(X, nx=20, ny=20)
quadrat.test(X, nx=20, ny=20)

对于大约 500k 点,用于样方的 20 x 20 网格对于样方计数来说似乎是一个非常大的空间尺度,但这当然取决于您的具体设置。

由于您没有提供可重现的示例,我不能说这些命令是否适用于您的设置,但它们确实适用于适当的数据。

于 2015-01-27T22:24:23.730 回答