-
Notifications
You must be signed in to change notification settings - Fork 2
/
Flowmapper_map_rectangle.R
84 lines (63 loc) · 1.88 KB
/
Flowmapper_map_rectangle.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#--------------------
# FLOWMAPPER carte Interactions rectangle (type = "rect")
# >> ligne 1356 et suivantes
#--------------------
# doit absolument être réalisée avec une matrice symétrique !
library("dplyr")
library("cartograflow")
#---------- fermeture de la matrice
# liste de codes des sous-régions
liste_subreg <- subregions %>% select(id)
liste_subreg <- as.data.frame(liste_subreg$id)
flow_sq <- flowcarre(
tab = flows,
liste = liste_subreg,
origin = "i",
dest = "j",
valflow = "fij",
format = "L",
diagonale = TRUE,
empty.sq = FALSE
)
colnames(flow_sq) <- c("i", "j","fij")
#-------- calcul du volume bilateral avec cartograflow
flow_bivol<- flowtype(flow_sq,origin ="i",destination="j",fij="fij",
format = "L", x = "bivolum", lowup = "up")
head(flow_bivol)
colnames(flow_bivol) <- c("i", "j","fij")
flow_bivol$i <- as.character(flow_bivol$i)
flow_bivol$j <- as.character(flow_bivol$j)
flow_bivol$fij <- as.numeric(flow_bivol$fij)
#---------- idem avec flowmapper_flowtypes
test2 <- flowtype(
flow_sq,
origin = "i",
destination = "j",
fij = "fij",
format = "L",
x = "bivolum",
lowup = "up"
)
#----------- cartographie des rectangles
#```{r, eval = TRUE, message = FALSE, warning = FALSE, results = "hide"}
template("Interactions", "maps/ttt_interactions_volume.png")
c <- ttt_flowmapper(
x = subregions,
xid = "id",
size = "thickness",
type = "rect",
df = flow_bivol, #matrice symétrique
dfid = c("i", "j"),
dfvar = "fij", #Somme des flux entrants et sortants
col = col,
border = "#424242",
border2 = col,
add = TRUE
)
dev.off()
#```
#ttt_interactions_vol.png : image où les bandes sont //
# on décide donc de prendre la partie supérieure
#<img src = "maps/ttt_interactions_vol.png"></img>
#ttt_interactions_volume.png : image OK
#<img src = "maps/ttt_interactions_volume.png"></img>