Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
YannFerro authored Jun 18, 2024
1 parent 1243d59 commit 1240faa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions R/mat_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
install.packages("osrm")
library(osrm)

####Chargement de la couche de points correspondant aux mairies des communes du Luxembourg
mairies_com_lux <- sf::read_sf("data/Mairies_W2_2018.shp")
names(mairies_com_lux)[2] <- "Mairie"
names(mairies_com_lux)[6] <- "Localité"
# ####Chargement de la couche de points correspondant aux mairies des communes du Luxembourg
source("R/data_osm.R")

mairies_com_lux <- sf::st_transform(all_mairies, crs = 2169)

####Calcul de distances en voitures (en m) entre les 100 premières communes et les 100 premières communes####
matdist <- osrm::osrmTable(src = mairies_com_lux$geometry[1:100], dst = mairies_com_lux$geometry[1:100], measure = "distance", osrm.profile = "car")
Expand Down Expand Up @@ -37,11 +37,11 @@ dist_4_2 <- rbind(dist_4, dist_2)
####Et les 102 colonnes avec les 102 lignes####
dist <- cbind(dist_1_3, dist_4_2)
#####Récupération des noms des communes
row.names(dist) <- mairies_com_lux$Mairie
colnames(dist) <- mairies_com_lux$Mairie
row.names(dist) <- mairies_com_lux$com
colnames(dist) <- mairies_com_lux$com

####Ecriture de la matrice####
write.csv(dist, "output/dist.csv")
write.csv(dist, "output/matrice_dist_car_lux.csv")

####Distances euclidiennes

Expand All @@ -53,8 +53,8 @@ matdisteucli <- as.data.frame.matrix(disteucli)
matdisteucli <- (matdisteucli/1000)

#####Récupération des noms des communes
row.names(matdisteucli) <- mairies_com_lux$Marie
colnames(matdisteucli) <- mairies_com_lux$Marie
row.names(matdisteucli) <- mairies_com_lux$com
colnames(matdisteucli) <- mairies_com_lux$com

####Ecriture de la matrice####
write.csv(matdisteucli, "output/disteucli.csv")
write.csv(matdisteucli, "output/matrice_dist_eucli_lux.csv")

0 comments on commit 1240faa

Please sign in to comment.