Skip to contents

These functions provide low level access to origin and destination local positions. It is recommended to use origin_positions() and destination_positions() instead of location_positions and location_positions<-.

Usage

location_positions(sim)

location_positions(sim) <- value

Arguments

sim

a spatial interaction model object

value

a list with two components (see the returned value) or NULL

Value

for location_positions NULL or a list with two components: origin for the origin location positions and destination for the destination location positions. For location_positions<-() the modified sim object.

Positions

Location positions are given by numeric matrices with 2 or 3 columns. The first two columns are assumed to be geographical coordinates while the 3rd column can be used for instance to store altitude. Coordinates are interpreted as is in graphical representations (see autoplot.sim()). They are not matched to the costs as those can be derived from complex movement models and other non purely geographic considerations.

Examples

positions <- matrix(rnorm(10 * 2), ncol = 2)
distances <- as.matrix(dist(positions))
production <- rep(1, 10)
attractiveness <- rep(1, 10)
model <- static_blvim(distances, production, 1.5, 1, attractiveness)
## No positions
location_positions(model) <- list(origin = positions, destination = positions)
destination_positions(model)
#>             [,1]        [,2]
#>  [1,] -0.3780286 -1.63463827
#>  [2,]  1.7361110 -0.01044112
#>  [3,] -0.8452478 -0.65650614
#>  [4,] -0.9615715 -0.66953344
#>  [5,]  1.0174911 -0.47858903
#>  [6,] -1.4960537  1.31945632
#>  [7,] -1.1848187  0.63656276
#>  [8,]  0.6302344  0.51432778
#>  [9,]  2.1012525 -1.75137511
#> [10,] -0.6137368  0.89359752
origin_positions(model)
#>             [,1]        [,2]
#>  [1,] -0.3780286 -1.63463827
#>  [2,]  1.7361110 -0.01044112
#>  [3,] -0.8452478 -0.65650614
#>  [4,] -0.9615715 -0.66953344
#>  [5,]  1.0174911 -0.47858903
#>  [6,] -1.4960537  1.31945632
#>  [7,] -1.1848187  0.63656276
#>  [8,]  0.6302344  0.51432778
#>  [9,]  2.1012525 -1.75137511
#> [10,] -0.6137368  0.89359752