1
如何以适当的方式分配一个巨大的距离矩阵,以避免“分配是 无法”错误。想象一下,你在一些 空间中有100000个随机点。如何巧妙地创建一个矩阵或“dist” - 对象,它代表DistMatrix的一半。也许它应该是另一个对象,它将能够有效地分配大量的距离。如何创建一个大距离矩阵?
你可以从以下链接polygonial对象: https://www.dropbox.com/sh/65c3rke0gi4d8pb/LAKJWhwm-l
# Load required packages
library(sp)
library(maptools)
library(maps)
# Load the polygonal object
x <- readShapePoly("vg250_gem.shp")
# Sample or Pick up a large Number of Points
# this command needs some minutes to be done.
# "coord" is SpatialPoints Object
n <- 1e5
coord <- spsample(x, n, "random")
# Try to measure the distances by dist()
DistMatrix <- dist([email protected])
Error: negative length vectors are not allowed
# Try to measure the distances by spDists()
DistMatrix <- spDists(coord)
Error: cannot allocate vector of size (some number) MB
# It seems that the problem lies on large matrix to be created.
如何为这个问题中的R可解为“N”的伟大数字。
说小批量做你只是指使用spDistsN1()?请如果你能澄清你的想法,它可以是有用的。提前致谢。 –
嗨。我不熟悉这种方法。但如果它适合你的话。实际上,我的意思是将距离矩阵分成子矩阵并逐个求解每个子矩阵。每次将结果保存在硬盘上。释放你的RAM。 –
你知道一些包加速简单的计算任务,如sum,sqrt等。我听说有一个允许的包,但我找不到任何包。 –