[R-sig-Geo] memory limitations to markstat

Ian Robertson igr at stanford.edu
Wed Jan 30 20:50:46 CET 2008


Hello all,

I have been running into memory-related problems trying to use markstat 
(with 'table' as its supplied function) to assemble tabulations of 
categorical marks within fixed distances around about 5000 points. 
Experimenting with random data suggests that my default memory settings 
allow markstat to handle around 3200 points. At 3225 points, I get the 
message "Error: cannot allocate vector of size 317.4 Mb". Does anyone 
know what vector R is trying to store? Can anyone suggest a work around? 
Here is some illustrative code based on random data:

library(spatstat)
npoints <- 3200 #works
#npoints <- 3225 #fails
east <- runif(npoints, 1, 100)
north <- runif(npoints, 1, 100)
mark <- ceiling(runif(npoints, 0, 4))
ppo1 <- ppp(east, north, c(0, 100), c(0, 100), marks=factor(mark))
mTab <- markstat(ppo1, R=5, table, exclude=T)

I imagine that the various K-function tools in spatstat have to be 
making tabulations similar to what I have attempted to do with markstat. 
I have experimented with Kdot, forcing it to do a similar amount of work 
by making all the marks the same. Kdot can handle at least 5000 points 
(but not 5500) but since it doesn't return any mark-tabulations, I don't 
think it will help me.

npoints <- 5000 #works
npoints <- 5500 #fails
east <- runif(npoints, 1, 100)
north <- runif(npoints, 1, 100)
mark <- rep(1, npoints)
ppo1 <- ppp(east, north, c(0, 100), c(0, 100), marks=factor(mark))
kd1 <- Kdot(ppo1, "1")
 
I expect I could divide my study area into several appropriately 
overlapping sections, apply markstat to each, and then reassemble a 
single set of tabulations by selecting the largest 'neighbourhood set' 
available for any cases that get tabulated in more than one section. 
This seems pretty messy, but may be the way to go--short of doing the 
work in GRASS.

Many thanks in advance for any help or advice.

Ian Robertson




More information about the R-sig-Geo mailing list