Skip to contents

Extract station-to-station distance matrix


bike_distmat(bikedb, city, expand = 0.5, long = FALSE, quiet = TRUE)



A string containing the path to the SQLite3 database. If no directory specified, it is presumed to be in tempdir().


City for which tripmat is to be aggregated


Distances are calculated by routing through the OpenStreetMap street network surrounding the bike stations, with the street network expanded by this amount to ensure all stations can be connected.


If FALSE, a square distance matrix of (num-stations, num_stations) is returned; if TRUE, a long-format matrix of (stn-from, stn-to, distance) is returned.


If FALSE, progress is displayed on screen


If long = FALSE, a square matrix of numbers of trips between each station, otherwise a long-form tibble with three columns of of (start_station_id, end_station_id, distance)


Distance matrices returned from bike_distamat use all stations listed for a given system, while trip matrices extracted with bike_tripmat will often have fewer stations because operational station numbers commonly vary over time. The two matrices may be reconciled with the match_trips2dists function, enabling then to be directly compared.