[R-sig-Geo] memory limitations to markstat

Ian Robertson igr at stanford.edu
Thu Jan 31 18:13:08 CET 2008


Hello Roger,

Many thanks indeed for the useful observations about the reasons for 
memory limitations in markstat, and a solution using maptools and 
spdep--this does what I want to quite nicely. I would also be quite 
interested in experimenting with the unreleased package you mention; I 
would prefer the Windows binary, please.

Best,

Ian Robertson

Roger Bivand wrote:
> Very useful example. If you say:
>
> debug(applynbd)
>
> and run markstat(), you see that it operates with at least four n by n 
> matrices, which get stacked in an array. I think your error exit is 
> when the big a is being created. It does not use quadtrees or similar 
> data structures. Kdot() uses a different internal infrastructure.
>
> If you are willing to try an alternative, I can let you try an 
> unreleased ANN tree-based package which has a heuristic distance 
> cutoff (it uses k-nearest neighbours, so k has to be adaptive in the 
> inverse of density). If your distances are small relative to the 
> total, this should work.
> Please say if you prefer a source or Windows binary package. Work is 
> going on to bring together several ports of ANN, but isn't ready yet.
>
> If a quicker and dirtier solution is acceptable, try:
>
> library(maptools)
> ppo1a <- as(ppo1, "SpatialPointsDataFrame")
> summary(ppo1a)
> d5nb <- dnearneigh(coordinates(ppo1a), 0, 5)
> mt <- sapply(d5nb, function(x) table(ppo1a$marks[x]))
> str(mt)
>
> mt will need transposing. Because dnearneigh() doesn't use a full or 
> triangular distance matrix, just distances for points one by one, its 
> memory footprint is small. d5nb is a list of neighbours within 
> distance 5, so can be used with sapply and lapply.
>
> Hope this helps,
>
> Roger




More information about the R-sig-Geo mailing list