[R-sig-Geo] skater - spdep runtime - geographic territories

Salo V @@|ov@|@berg @end|ng |rom gm@||@com
Tue Jun 11 22:21:46 CEST 2019


Hi Everyone,

I am trying to run the skater function for graph partitions, part of the
spdep package. My goal is to create contiguous territories for the entire
USA at the ZIP Code level.

The function takes a very long time to run even for ~15% of my total areas.
I am looking to run this for the 30,000 ZIP Codes in the USA.

The skater function documentation gives an example of parallel processing,
but it doesn’t seem to be speeding things up. I have a windows laptop with
2 physical cores and 4 logical cores. In the below code, I have already
tried to set nc = 1, nc=2 and nc=4 all with very similar results in time.

Has anyone been able to run the skater function for a large amount of areas
in a reasonable amount of time? Would really appreciate any guidance on
this, perhaps I am missing steps.



Here is the example from the documentation and which I am also running.

*library*(parallel)

nc <- detectCores(logical=FALSE)

# set nc to 1L here

*if* (nc > 1L) nc <- 1L

coresOpt <- get.coresOption()

invisible(set.coresOption(nc))

*if*(!get.mcOption()) {

# no-op, "snow" parallel calculation not available

  cl <- makeCluster(get.coresOption())

  set.ClusterOption(cl)

}

### calculating costs

system.time(plcosts <- nbcosts(bh.nb, dpad))

all.equal(lcosts, plcosts, check.attributes=FALSE)

### making listw

pnb.w <- nb2listw(bh.nb, plcosts, style="B")

### find a minimum spanning tree

pmst.bh <- mstree(pnb.w,5)

### three groups with no restriction

system.time(pres1 <- skater(pmst.bh[,1:2], dpad, 2))

*if*(!get.mcOption()) {

  set.ClusterOption(NULL)

  stopCluster(cl)

}


much appreciated!

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list