[英]Is there a way to perform quadratcount() in spatstat without ignoring the marks?
Imagine I have a point pattern distribution in a square and all points have marks (ie plant trait data).想象一下,我在一个正方形中有一个点模式分布,并且所有点都有标记(即植物性状数据)。 I want to divide this square in fe 4 quadrats.
我想把这个正方形分成 fe 4 个样方。 Now I am interested in the spatial distribution of the traits, ie I need to now which trait occurs in which quadrat.
现在我对特征的空间分布感兴趣,即我现在需要知道哪个特征出现在哪个样方中。 Only counting the number of points per quadrats does not help in this case, i need to know the points + marks.
在这种情况下,仅计算每个样方的点数无济于事,我需要知道点数 + 标记。 However, quadratcount ignores the marks.
但是,quadratcount 会忽略这些标记。 The split-function does not really help as one would need to combine the results per quadrat afterwards, that is not really practical.
拆分函数并没有真正帮助,因为之后需要将每个样方的结果组合起来,这并不实用。
# let's try the ant-dataset and count ants in 2x2 quadrats
quadratcount(ants, 2,2)
# raw number of points
x
y [-25,389) [389,803]
[334,717] 22 20
[-49,334) 27 28
# let's count the abundance of different groups of marks per quadrat
quadratcount(split(ants), 2,2)
Cataglyphis:
x
y [-25,389) [389,803]
[334,717] 5 3
[-49,334) 9 12
Messor:
x
y [-25,389) [389,803]
[334,717] 17 17
[-49,334) 18 16
[UPDATE] [更新]
I would need a dafaframe with the coordinates corresponding to each mark, grouped by quadrats.我需要一个 dafaframe,其坐标对应于每个标记,按样方分组。 With extracted x/y values including the marks.
提取的 x/y 值包括标记。 I can do it manually, but it is not very elegant.
我可以手动完成,但不是很优雅。 It might look like this:
它可能看起来像这样:
$q1[(-25, 389), -49, 334)]
x y marks
x y V3
29 275 325 Messor
36 2 267 Messor
39 124 293 Messor
40 197 207 Messor
41 218 297 Messor
42 236 241 Messor
43 298 271 Messor
44 345 239 Messor
45 388 287 Messor
50 289 188 Messor
51 331 145 Messor
66 236 205 Messor
76 326 303 Cataglyphis
80 -7 233 Cataglyphis
83 233 256 Cataglyphis
84 364 239 Cataglyphis
89 324 101 Cataglyphis
$q2[(-25, 389), (334,717)]
x y marks
...
$q3[(389,803), (334,717)]
x y marks
...
$q4[(389,803), (-49,334)]
x y marks
...
Wondering if someone understand my problem, looking forward to any ideas!想知道是否有人理解我的问题,期待任何想法!
It's unclear exactly what you want.目前还不清楚你到底想要什么。 The
quadratcount
function counts the number of points falling in each sub-region. quadratcount
function 统计落在每个子区域的点数。 If you want to retain the actual point coordinates, then quadratcount
is not the appropriate function. You can use methods for split
and cut
to sub-divide the point pattern while retaining the coordinates.如果要保留实际的点坐标,那么
quadratcount
不是合适的function。可以使用split
和cut
的方法,在保留坐标的情况下对点图进行细分。
I'll make two guesses.我会做两个猜测。
ants
data):ants
数据进行了演示):B <- quadrats(ants, 2, 2)
Y <- split(ants, B)
Z <- lapply(Y, as.data.frame)
where B
is a tessellation object (class tess
) specifying the four tiles;其中
B
是镶嵌 object(类tess
),指定四个图块; Y
is a list containing the four subsets of the point pattern ants
within these four tiles; Y
是包含这四个图块中点模式ants
的四个子集的列表; and Z
is a list of data frames with columns x, y, marks
. Z
是包含列x, y, marks
的数据框列表。
The split-function does not really help as one would need to combine the results per quadrat afterwards, that is not really practical.
拆分函数并没有真正帮助,因为之后需要将每个样方的结果组合起来,这并不实用。
If you just want to know, for each tile, the number of points of each type that fall in the tile, you could do如果您只想知道对于每个图块,落在图块中的每种类型的点数,您可以这样做
simplify2array(quadratcount(split(ants, 2, 2)))
which produces a 3D array containing these numbers.生成包含这些数字的 3D 数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.