简体   繁体   English

有没有办法在不忽略标记的情况下在 spatstat 中执行 quadratcount()?

[英]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。可以使用splitcut的方法,在保留坐标的情况下对点图进行细分。

I'll make two guesses.我会做两个猜测。

  1. It seems you probably want something like this (demonstrated for the 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的数据框列表。

  1. Responding to your comment that回应你的评论

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.

相关问题 R-spatstat:使用nnwhich后如何关联2个标记 - R-spatstat: How to relate 2 marks after using nnwhich 如何在循环/应用命令中为spatstat对象分配标记? - How to assign marks to spatstat objects within loops / apply commands? spatstat从点模式中删除标记,然后删除这些点 - spatstat deleting marks from a point pattern and subseuently the points 从 Spatstat 中的最近邻标记创建新数据框 - Create new data frame from nearest neighbour marks in Spatstat 是否可以在 Rstudio 中使用 SpatStat 向 3D 点模式添加标记? - Is it possible to add marks to a 3D point pattern using SpatStat in Rstudio? Spatstat:有没有办法测试各向异性,尤其是在有聚类的情况下 - Spatstat: Is there a way to test for anisotrophy, especially when there is clustering 在没有重叠点的情况下绘制spatstat中的残差 - plot residuals in spatstat without overlaying points 寻找使用`linearKEuclid`和`spatstat`的相应功能的方法 - Searching for a way to use `linearKEuclid` and corresponding functions of `spatstat` 有没有办法在“spatstat”包中使圆盘图的多边形边界不可见? - Is there a way to render invisible the polygonal boundary of a disc plot in the 'spatstat' package? 如何在 Spatstat 中创建带有覆盖两个标记的图例的组合颜色图? - How do I create a combined colour plot with legend overlaying two marks in Spatstat?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM