最近邻标记的平均值(空间点模式)markmean

时间:2016-03-09 16:59:27

标签: r spatial point nearest-neighbor spatstat

我试图获得每个点的标记的平均值,计算每个点周围特定距离处的所有可用点,包括我们测量的点。

我使用了带缓冲区的markmean(){spatstats},但我不确定它是否正在做我想做的事。

这是我想要做的一个简单示例:

public interface ICovariant<out T> { }
public interface IContravariant<in T> { }

public class Covariant<T> : ICovariant<T> { }
public class Contravariant<T> : IContravariant<T> { }

public class Fruit { }
public class Apple : Fruit { }

public class TheInsAndOuts
{
    public void Covariance()
    {
        ICovariant<Fruit> fruit = new Covariant<Fruit>();
        ICovariant<Apple> apple = new Covariant<Apple>();

        Covariant(fruit);
        Covariant(apple); //apple is being upcasted to fruit, without the out keyword this will not compile
    }

    public void Contravariance()
    {
        IContravariant<Fruit> fruit = new Contravariant<Fruit>();
        IContravariant<Apple> apple = new Contravariant<Apple>();

        Contravariant(fruit); //fruit is being downcasted to apple, without the in keyword this will not compile
        Contravariant(apple);
    }

    public void Covariant(ICovariant<Fruit> fruit) { }

    public void Contravariant(IContravariant<Apple> apple) { }
}

空间点看起来像这样:

Point distribution with IDs and marks (marks are in point 13=60,in point 14=40, for the rest of the points the mark is 0 当然,我的实际数据不遵循常规模式,因​​此点之间的距离是可变的。

我希望对于带有西格玛1的第13点,markmean是:(60 + 40 + 0 + 0 + 0)/ 5 = 20或者对于第7点,标记的意思是:(60 + 0 + 0 + 0 + 0)/ 5 = 12。

但是按照上面的代码我得到了:

ICovariant<Fruit> apple = new Covariant<Apple>(); //because it's covariant
IContravariant<Apple> fruit = new Contravariant<Fruit>(); //because it's contravariant

你知道为什么我得到这些结果吗? 你如何正确计算某个缓冲区内每个点周围标记的平均值?

非常感谢您的时间和帮助!

1 个答案:

答案 0 :(得分:0)

函数java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.计算点数字标记的平滑空间平均值。我相信你正在寻找函数markmean,它可以计算每个点附近点的任何统计量。该函数具有参数markstat(标记点模式),X(在您的情况下使用的汇总函数 - fun)和mean(通过定义邻居N最接近每个点的点数)或N(按每个点周围的半径定义邻居,这就是你想要的):

R

然后library(spatstat) p <- 1:25 #points ID x <- rep(4:0, each = 5) #x location y <- rep(0:4, times = 5) #y location i <- c(rep(0, 12), 60, 40, rep(0, 11)) #mark or value in each point w <- square(4) # window needed to create ppp table <- data.frame(p, x, y, i) X <- with(table, ppp(x, y, marks = i, window = w)) meanmarkstable <- markstat (X, fun = mean, R=1) tableresults <- cbind(table, neigh_mean = meanmarkstable) 包含以下内容:

tableresults