allocate: Teitz-Bart algorithm applied to Spatial* and...

Description Usage Arguments Value Examples

View source: R/tbmain.R

Description

This function returns the allocations for each demand point - in terms of the index number of the record in swdf2 assigned as the supply point. This version is useful as part of code inside other functions

Usage

1
allocate(swdf1, swdf2, force, p, metric, verbose = FALSE)

Arguments

swdf1

- first Spatial* or Spatial*DataFrame objects

swdf2

- second Spatial* or Spatial*DataFrame objects (if omitted, defaults to the same value as swdf1)

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 existing outlets

p

- either a guess at the initial p-median set of a single integer indicating the size of the set (which is then chosen randomly)

metric

- the distance matrix (defaults to Euclidean computed via euc.dists(swdf1,swdf2) if not supplied)

verbose

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

Value

List of nearest neigbour indices for each element from the p-median set

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(meuse)
coordinates(meuse) <- ~x+y
allocate(meuse,p=5)



require(RColorBrewer)
require(GISTools)
data(georgia)
allocations.list <- allocate(georgia2,p=5)
zones <- gUnaryUnion(georgia2,allocations.list)
plot(zones,col=brewer.pal(5,"Accent"))
plot(georgia2,border=rgb(0,0,0,0.1),add=TRUE)
points(coordinates(georgia2)[allocations.list,],pch=16,cex=2,col=rgb(1,0.5,0.5,0.1))

tbart documentation built on May 20, 2017, 3:56 a.m.

Search within the tbart package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.