我需要绘制一个全国性的栅格。我试过 cellsize=300 并使用 64 位系统。Memory.limit() 是 8148。运行代码时,它仍然给我一个“错误:无法分配大小为 3.6 Gb 的向量”。有时,Windows 会停止工作——更糟糕的是......
有没有其他方法可以处理这么大的数据集?顺便说一句,我更熟悉ArcGIS。谢谢!!!
{
x.min <- -6328997.74765339; x.max <- 2182662.25234661 # Extent of easting coordinates
y.min <- 310413.438361092; y.max <- 5448183.43836109 # Extent of northing coordinates
n <- 2351
center <- read.csv ("J:\\...,header=T)
attach(center)
center <- as.matrix (center) # XY corrdinates #
emp <- read.csv ("J:\\...,header=T, sep=",")
attach(emp)
n.rows <- 17126
cellsize <- 300
n.cols <- 28373
x.max <- x.min + n.cols * cellsize # Assures square cells are used#
y.0 <- seq(y.max-cellsize/2, y.min+cellsize/2, length.out=n.rows)
x.0 <- seq(x.min+cellsize/2, x.max-cellsize/2, length.out=n.cols)
system.time(
{
i <- order(emp, decreasing=TRUE)
emp <- emp[i]
center <- center[i, , drop=FALSE]
owner <- matrix(0, n.rows, n.cols)
gravity.max <- matrix(0, n.rows, n.cols)
for (i in 1:n) {
r <- emp[i] / outer((y.0 - center[i,2])^2, (x.0 - center[i,1])^2, "+")
update <- which(r >= gravity.max)
gravity.max[update] <- r[update]
owner[update] <- i
}
})