处理庞大的数据集?

时间:2013-07-04 07:50:47

标签: raster maxlength large-data

我需要绘制全国范围的光栅。我尝试使用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
    }  
  })

1 个答案:

答案 0 :(得分:1)

您可以尝试raster package

raster可以使用大型栅格。许多在R中进行空间分析的人都使用它。

如果您第一次阅读小插图Introduction to the raster package以熟悉该软件包,则可以节省大量时间。

相关问题