2013-07-04 176 views
0

我需要繪製一個全國範圍的柵格。我試過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 
    } 
    }) 

回答