Description Usage Arguments Value Examples

Return demand Spatial*Dataframe with new columns giving allocation id and distance to supply point

1 | ```
allocations(swdf1, swdf2, force, p, metric, verbose = FALSE)
``` |

`swdf1` |
- first Spatial* or Spatial*DataFrame objects |

`swdf2` |
- second Spatial* or Spatial*DataFrame objects (if omitted, defaults to the same value as |

`force` |
- list of supply points or logical vector with length the same as the number of supply points that are forced to be used - eg e |

`p` |
- either a guess at the initial |

`metric` |
- the distance matrix (defaults to Euclidean computed via |

`verbose` |
- if TRUE print out each swap in the algorithm (default is FALSE) |

Copy of swdf1 with extra data columns called `allocation`

and `allocdist`

with indices for each element from the *p*-median set

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
require(RColorBrewer)
require(GISTools)
data(georgia)
georgia3 <- allocations(georgia2,p=5,force=c(1,120,44))
col.index <- match(georgia3$allocation,unique(georgia3$allocation))
col.alloc <- brewer.pal(5,'Accent')[col.index]
par(mfrow=c(1,2))
plot(georgia3,col=col.alloc)
choropleth(georgia3,georgia3$allocdist)
# Use in conjunction with rgeos
require(rgeos)
require(GISTools)
georgia3 <- allocations(georgia2,p=5,force=c(1,120,44))
georgia4 <- gUnaryUnion(georgia3,georgia3$allocation)
plot(georgia4)
plot(star.diagram(georgia3),col='darkred',lwd=2,add=TRUE)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.