This function takes a matrix representing travel between origins (with origin codes in the rownames of the matrix) and destinations (with destination codes in the colnames of the matrix) and returns a data frame representing origin-destination pairs.

odmatrix_to_od(odmatrix)

Arguments

odmatrix

A matrix with row and columns representing origin and destination zone codes and cells representing the flow between these zones.

Details

The function returns a data frame with rows ordered by origin and then destination zone code values and with names orig, dest and flow.

See also

Other od: od_id, od_to_odmatrix()

Examples

x = od_data_df
x[1:3]
#>   geo_code1 geo_code2  all
#> 1 E02002384 E02006875  966
#> 2 E02002404 E02006875 1145
#> 3 E02006875 E02006875 1791
#> 4 E02006876 E02006875 1035
#> 5 E02006861 E02002392  453
#> 6 E02006875 E02002392  286
#> 7 E02002392 E02006875  753
odmatrix = od_to_odmatrix(od_data_df)
odmatrix
#>           E02006875 E02002392
#> E02002384       966        NA
#> E02002404      1145        NA
#> E02006875      1791       286
#> E02006876      1035        NA
#> E02006861        NA       453
#> E02002392       753        NA
odmatrix_to_od(odmatrix)
#>         orig      dest flow
#> 1  E02002384 E02006875  966
#> 6  E02002392 E02006875  753
#> 2  E02002404 E02006875 1145
#> 11 E02006861 E02002392  453
#> 9  E02006875 E02002392  286
#> 3  E02006875 E02006875 1791
#> 4  E02006876 E02006875 1035