-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.R
More file actions
223 lines (197 loc) · 10 KB
/
map.R
File metadata and controls
223 lines (197 loc) · 10 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
library(tidyverse)
library(maps)
library(plotly)
# MD All -----------------------------------------
## Create data frame of lab cities -----
data("world.cities")
md_cities <- world.cities %>%
filter((name == "Auburn" & country.etc == "USA" & lat == 32.59) |
(name == "Boston" & country.etc == "USA") |
(name == "Budapest" & country.etc == "Hungary") |
(name == "Buenos Aires" & country.etc == "Argentina") |
(name == "Durham" & country.etc == "USA") |
(name == "Kingston" & country.etc == "Canada") |
(name == "Lexington" & country.etc == "USA") |
(name == "Lincoln" & country.etc == "USA" & lat == 40.82) |
(name == "Messina" & country.etc == "Italy") |
(name == "New Haven" & country.etc == "USA") |
(name == "New York" & country.etc == "USA") |
(name == "Portsmouth" & country.etc == "UK") |
(name == "Providence" & country.etc == "USA") |
(name == "Rijeka" & country.etc == "Croatia") |
(name == "Rochester Hills" & country.etc == "USA") |
(name == "Saint John's" & country.etc == "Canada") |
(name == "Santa Rosa" & country.etc == "USA") |
(name == "Tucson" & country.etc == "USA") |
(name == "Vienna" & country.etc == "Austria") |
(name == "Warsaw" & country.etc == "Poland") |
(name == "Winchester" & country.etc == "UK") |
(name == "Winnipeg" & country.etc == "Canada")
) %>%
select(city = name, country = country.etc, lat, long) %>%
mutate(lab = c("Canine Performance Sciences, Auburn University",
"Canine Cognition Center, Boston College",
"The Family Dog Project, Eötvös Loránd University",
"Canid Behavior Research Group, National Scientific and Technical Research Council",
"Duke Canine Cognition Center, Duke University",
"Social Cognition Lab, Queen’s University",
"Transylvania University",
"Canine Cognition and Human Interaction Lab, University of Nebraska-Lincoln ",
"Pet Behaviour Consulting, Università degli Studi di Messina",
"Canine Cognition Center, Yale University",
"Thinking Dog Center, Hunter College",
"Dog Cognition Centre, University of Portsmouth",
"Brown Dog Lab, Brown University",
"Comparative Cognitive Science Lab, University of Rijeka",
"Leader Dogs for the Blind",
"Canine Research Unit, Memorial University",
"Canine Companions",
"Arizona Canine Cognition Center, University of Arizona",
"The Clever Dog Lab, University of Veterinary Medicine Vienna",
"Department of Psychology of Individual Differences, University of Warsaw",
"Animal Health and Welfare Centre, University Centre Sparsholt",
"Comparative Cognition Lab, University of Manitoba"),
.before = 1) #%>%
# add_row(lab = "lab name", city = "city", country = "country", lat = 46.73, long = -117.17)
## Plot labs -------------------------------------------------
# geo styling
md_labs <- list(
scope = 'world',
showland = TRUE,
landcolor = toRGB("grey83"),
subunitcolor = toRGB("white"),
countrycolor = toRGB("white"),
coastlinecolor = toRGB("white"),
showlakes = FALSE,
# lakecolor = toRGB("white"),
showsubunits = FALSE,
showcountries = TRUE,
resolution = 50,
lonaxis = list(
showgrid = FALSE,
gridwidth = 0.5,
range = c(-130, 30),
dtick = 5
),
lataxis = list(
showgrid = FALSE,
gridwidth = 0.5,
range = c(-45, 60),
dtick = 5
)
)
md_labs_fig <- plot_geo(md_cities, lat = ~lat, lon = ~long, size = 100) %>%
add_markers(text = ~md_cities$lab, hoverinfo = "text",
marker=list(sizeref=0.5, sizemode="area")) %>%
layout(geo = md_labs, margin = list(t = 0, r = 0, b = 0, l = 0))
md_labs_fig
save_image(md_labs_fig, "md_labs.png")
htmlwidgets::saveWidget(partial_bundle(md_labs_fig), "md_labs.html", selfcontained = FALSE, libdir = "lib")
file.copy(from = "md_labs.html", to = "../manydogsproject.github.io/_site/images/html/md_labs.html", overwrite = TRUE)
file.copy(from = "lib", to = "../manydogsproject.github.io/docs/images/html", overwrite = TRUE, recursive = TRUE)
file.copy(from = "md_labs.html", to = "/home/jstevens/github/manydogsproject.github.io/images/html/md_labs.html", overwrite = TRUE)
file.copy(from = "lib", to = "/home/jstevens/github/manydogsproject.github.io/images/html", overwrite = TRUE, recursive = TRUE)
# file.copy(from = "lib", to = "/home/jstevens/github/manydogsproject.github.io/_site/images/html", overwrite = TRUE, recursive = TRUE)
# MD 1 -----------------------------------------
## Create data frame of lab cities -----
md1_cities <- world.cities %>%
filter((name == "Auburn" & country.etc == "USA" & lat == 32.59) |
(name == "Boston" & country.etc == "USA") |
(name == "Budapest" & country.etc == "Hungary") |
(name == "Buenos Aires" & country.etc == "Argentina") |
(name == "Durham" & country.etc == "USA") |
(name == "Kingston" & country.etc == "Canada") |
# (name == "Lexington" & country.etc == "USA") |
(name == "Lincoln" & country.etc == "USA" & lat == 40.82) |
(name == "Messina" & country.etc == "Italy") |
(name == "New Haven" & country.etc == "USA") |
(name == "New York" & country.etc == "USA") |
(name == "Portsmouth" & country.etc == "UK") |
(name == "Providence" & country.etc == "USA") |
(name == "Rijeka" & country.etc == "Croatia") |
(name == "Rochester Hills" & country.etc == "USA") |
(name == "Saint John's" & country.etc == "Canada") |
(name == "Santa Rosa" & country.etc == "USA") |
(name == "Tucson" & country.etc == "USA") |
(name == "Vienna" & country.etc == "Austria") |
(name == "Warsaw" & country.etc == "Poland") |
(name == "Winchester" & country.etc == "UK") |
(name == "Winnipeg" & country.etc == "Canada")
) %>%
select(city = name, country = country.etc, lat, long) %>%
mutate(lab = c("Canine Performance Sciences, Auburn University",
"Canine Cognition Center, Boston College",
"The Family Dog Project, Eötvös Loránd University",
"Canid Behavior Research Group, National Scientific and Technical Research Council",
"Duke Canine Cognition Center, Duke University",
"Social Cognition Lab, Queen’s University",
# "Transylvania University",
"Canine Cognition and Human Interaction Lab, University of Nebraska-Lincoln ",
"Pet Behaviour Consulting, Università degli Studi di Messina",
"Canine Cognition Center, Yale University",
"Thinking Dog Center, Hunter College",
"Dog Cognition Centre, University of Portsmouth",
"Brown Dog Lab, Brown University",
"Comparative Cognitive Science Lab, University of Rijeka",
"Leader Dogs for the Blind",
"Canine Research Unit, Memorial University",
"Canine Companions",
"Arizona Canine Cognition Center, University of Arizona",
"The Clever Dog Lab, University of Veterinary Medicine Vienna",
"Department of Psychology of Individual Differences, University of Warsaw",
"Animal Health and Welfare Centre, University Centre Sparsholt",
"Comparative Cognition Lab, University of Manitoba"),
.before = 1) #%>%
# add_row(lab = "lab name", city = "city", country = "country", lat = 46.73, long = -117.17)
## Plot labs -------------------------------------------------
# geo styling
md1_labs <- list(
scope = 'world',
showland = TRUE,
landcolor = toRGB("grey83"),
subunitcolor = toRGB("white"),
countrycolor = toRGB("white"),
coastlinecolor = toRGB("white"),
showlakes = FALSE,
# lakecolor = toRGB("white"),
showsubunits = FALSE,
showcountries = TRUE,
resolution = 50,
lonaxis = list(
showgrid = FALSE,
gridwidth = 0.5,
range = c(-130, 30),
dtick = 5
),
lataxis = list(
showgrid = FALSE,
gridwidth = 0.5,
range = c(-45, 60),
dtick = 5
)
)
md1_labs_fig <- plot_geo(md1_cities, lat = ~lat, lon = ~long, size = 100) %>%
add_markers(text = ~md1_cities$lab, hoverinfo = "text",
marker=list(sizeref=0.5, sizemode="area")) %>%
layout(geo = md1_labs, margin = list(t = 0, r = 0, b = 0, l = 0))
md1_labs_fig
# save_image(md1_labs_fig, "md1_labs.png")
# htmlwidgets::saveWidget(partial_bundle(md1_labs_fig), "md1_labs.html", selfcontained = FALSE, libdir = "lib")
# file.copy(from = "md1_labs.html", to = "../manydogsproject.github.io/_site/images/html/md1_labs.html", overwrite = TRUE)
# file.copy(from = "lib", to = "../manydogsproject.github.io/docs/images/html", overwrite = TRUE, recursive = TRUE)
# file.copy(from = "lib", to = "/home/jstevens/github/manydogsproject.github.io/_site/images/html", overwrite = TRUE, recursive = TRUE)
# MD Intro ----------------------------------------------------------------
mdintro_only <- world.cities %>%
filter((name == "Cambridge" & country.etc == "USA") |
(name == "Washington" & country.etc == "USA")) |>
select(city = name, country = country.etc, lat, long) %>%
mutate(lab = c("Harvard University",
"The George Washington University"),
.before = 1)
mdintro_cities <- md1_cities |>
bind_rows(mdintro_only)
mdintro_labs_fig <- plot_geo(mdintro_cities, lat = ~lat, lon = ~long, size = 100, width = 600) %>%
add_markers(text = ~mdintro_cities$lab, marker=list(sizeref = 0.75, sizemode = "area")) %>%
layout(geo = md1_labs, margin = list(t = 0, r = 0, b = 0, l = 0))
mdintro_labs_fig
# save_image(mdintro_labs_fig, "mdintro_labs.png", width = 1180, height = 800, scale = 1.2)