<- c("a", "b", "c", "d")
x
combn(x, m = 2)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "a" "a" "a" "b" "b" "c"
[2,] "b" "c" "d" "c" "d" "d"
Distance information between places is useful to evaluate the proximity and interconnection of regions. The Euclidean distance between two places, although simple and easy to compute, is not realistic in terms of dislocation costs. This dataset present the road distance and trip duration metrics between all Brazilian municipalities.
As reference to starting and ending point of the routes, I opted to use the municipality seat localization (“sede dos municípios”), which is usually the city hall or historic downtown localization. This data is originally generated by the Brazilian Institute of Geography and Statistics (IBGE) and available on the {geobr} package. The last available data is for the year of 20101 and present 5,565 features.
With the list of municipalities and respective seat geographic coordinates, a list of pairs of municipalities is computed using simple combinatorial analysis. Example:
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "a" "a" "a" "b" "b" "c"
[2,] "b" "c" "d" "c" "d" "d"
With this, I assume that the distance between two municipalities is the same, independently of the direction.
Thus, for the 5,565 municipalities, we will have a total number of routes to be computed:
To compute the road distance between pairs of municipalities, the OSRM API service was used, with the {osrm} package (Giraud 2022). More specifically, the table service was used, considering the “car” profile, returning as result the distance in meters and estimated trip duration in minutes for the fastest route found.
For example, lets compute the road distance between Rio de Janeiro, RJ and São Paulo, SP with the {osrm} package.
For some pairs of municipalities, the OSRM service is not able to determine a possible road route. This is expected, as some municipalities are reachable only by plane or boat.
The scripts used to prepare the dataset are available here.
The dataset with the road distances and trip duration are available on Zenodo, on RDS format, parquet format, and CSV (zipped) format.
Click the link below to access and download the data.
You can also download the dataset directly from R, using the {zendown} package.
# install.packages("zendown")
library(zendown)
dist_brasil_file <- zen_file(11400243, "dist_brasil.rds")
dist_brasil <- readRDS(dist_brasil_file)
head(dist_brasil)
orig dest dist dur
1 1100015 1100023 330534 313.6
2 1100015 1100031 397600 380.7
3 1100015 1100049 112805 113.9
4 1100015 1100056 390938 373.2
5 1100015 1100064 353606 333.9
6 1100015 1100072 321636 348.5
Compute routes using other available routing services.
Yearly updates of the dataset, as the road infrastructure may change.
As new data for the 2022 Brazilian Census be available, the dataset will be likely updated.↩︎