-
Notifications
You must be signed in to change notification settings - Fork 3
/
sample_maps.Rmd
217 lines (152 loc) · 8.93 KB
/
sample_maps.Rmd
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
---
title: "Sample maps"
output:
html_document: default
pdf_document: default
word_document: default
date: 'Version: `r Sys.Date()`'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Here are some sample maps made in [Lingtypology](https://ropensci.org/blog/2017/05/16/lingtypology/) for R with the Daghestanian villages and languages dataset.
See the `sample_maps.rmd` file in the [repository](https://github.com/sverhees/master_villages) for the code used to draw these maps.
```{r, echo=FALSE, warning=FALSE, message=FALSE}
# packages
library(tidyverse) # data manipulation
library(lingtypology) # drawing maps
```
```{r, echo=FALSE, warning=FALSE, message=FALSE}
# load data
vill <- read_tsv("data/villages.csv") # dataframe with all villages, coordinates and languages
meta <- read_tsv("data/meta.csv") # dataframe with language metadata and color schemes
# data preparation
vill <- vill[complete.cases(vill$lat),] # remove villages without coordinates
meta_core <- meta %>% # remove idioms not (yet) recognized as distinct
filter(core == "yes")
vill_meta <- merge(vill, meta_core, by = "lang") # merge villages with metadata
```
## Map with all villages by language
The color scheme on this map more or less reflects genetic affiliation in the East Caucasian family, based on the ordering in [this family tree by Schulze (2009)](https://en.wikipedia.org/wiki/Northeast_Caucasian_languages#/media/File:Northeast_Caucasian_Splits.png). Unrelated languages are shades of grey and white. Hover over a dot to see the language spoken in a particular village.
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
# re-order the elements in the legend (by default they are in alphabetical order)
vill_meta$lang <- factor(vill_meta$lang, levels =c(
"Dargwa", "Lak", "Bats", "Ingush", "Chechen", "Khinalug", "Archi", "Tsakhur", "Rutul", "Kryz", "Budukh", "Udi", "Lezgian", "Agul", "Tabasaran", "Avar", "Andi", "Botlikh", "Godoberi", "Chamalal", "Bagvalal", "Tindi", "Karata", "Akhvakh", "Tsez", "Hinuq", "Bezhta", "Hunzib", "Khwarshi", "Nogai", "Kumyk", "Azerbaijani", "Armenian", "Tat", "Georgian"))
# draw map
map.feature(lang.gltc(vill_meta$glottocode),
latitude = vill_meta$lat,
longitude = vill_meta$lon,
features = vill_meta$lang,
color = vill_meta$lang_color,
label = vill_meta$lang,
zoom.control = T,
popup = vill_meta$village,
tile = c("Esri.WorldTopoMap"))
```
## Map with all villages by genealogical group
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
vill_meta$aff <- factor(vill_meta$aff, levels =c("Dargwa", "Lak", "Nakh", "Khinalug", "Lezgic", "Avar", "Andic", "Tsezic", "Kipchak", "Oghuz", "Armenic", "Iranian", "Georgic"))
map.feature(lang.gltc(vill_meta$glottocode),
latitude = vill_meta$lat,
longitude = vill_meta$lon,
features = vill_meta$aff,
width = 8,
label = vill_meta$lang,
color = vill_meta$aff_color,
zoom.control = T,
popup = vill_meta$village,
tile = c("Esri.WorldTopoMap"))
```
## Map with all villages by language + general datapoints
A lighter version of the previous colorscheme is also available. The idea is that you can use the lighter shades for all villages, and the brighter colors for villages that you have data for. Below is an example with general datapoints (i.e. one point for each traditionally recognized language and coordinates from the [Glottolog](https://glottolog.org/) database).
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
meta_core$emphasis <- "emphasis"
map.feature(lang.gltc(vill_meta$glottocode),
latitude = vill_meta$lat,
longitude = vill_meta$lon,
features = vill_meta$lang,
color = vill_meta$lang_color_pale,
label = vill_meta$lang,
zoom.control = T,
popup = vill_meta$village,
tile = c("Esri.WorldTopoMap")) %>%
map.feature(lang.gltc(meta_core$glottocode),
latitude = meta_core$gen_lat,
longitude = meta_core$gen_lon,
features = meta_core$lang,
legend = FALSE,
stroke.features = meta_core$emphasis,
stroke.color = "black",
stroke.legend = F,
width = 3, stroke.radius = 5,
label = meta_core$lang,
color = meta_core$lang_color,
zoom.control = T,
pipe.data = .)
```
## Map with only general datapoints
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
meta_core$lang <- factor(meta_core$lang, levels =c(
"Dargwa", "Lak", "Bats", "Ingush", "Chechen", "Khinalug", "Archi", "Tsakhur", "Rutul", "Kryz", "Budukh", "Udi", "Lezgian", "Agul", "Tabasaran", "Avar", "Andi", "Botlikh", "Godoberi", "Chamalal", "Bagvalal", "Tindi", "Karata", "Akhvakh", "Tsez", "Hinuq", "Bezhta", "Hunzib", "Khwarshi", "Nogai", "Kumyk", "Azerbaijani", "Armenian", "Tat", "Georgian"))
map.feature(lang.gltc(meta_core$glottocode),
latitude = meta_core$gen_lat,
longitude = meta_core$gen_lon,
features = meta_core$lang,
label = meta_core$lang,
color = meta_core$lang_color,
zoom.control = T)
```
## Altitude of datapoints
The altitude for each datapoint was retrieved automatically from Google, as were the coordinates for each village. These coordinates are not always precisely in the centre of the village, and as a result, the altitude data contains some inaccuracies. The highest village in this dataset, for example, is the village Asha (Tsumadinsky district), while we know that the highest village in Daghestan is actually Kurush (Dokuzparinsky district).
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
# round off elevation to two decimals
vill_meta <- vill_meta %>%
mutate(round = round(elevation, 2))
map.feature(lang.gltc(vill_meta$glottocode),
latitude = vill_meta$lat,
longitude = vill_meta$lon,
features = vill_meta$round,
title = "Altitude",
popup = paste(vill_meta$village, "<br>", "Meters above sea-level:", vill_meta$elevation))
```
## Kutans
The northern part of Dagestan was uninhabited until relatively recently. It is composed of an ethnic and linguistic mish-mash of resettlers. We have little to zero information about the language varieties spoken here, and due to their recent migration we cannot extend the areal patterns from the general region to this particular are. Therefore, we created a parameter with the label **kutans** (which refers to this type of resettler villages), which gives us the ability to filter out this type of villages.
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
vill_meta$lang <- as.character(vill_meta$lang)
vill_meta_kutans <- vill_meta %>%
mutate(
kutanlang = case_when(
kutans == FALSE ~ lang,
TRUE ~ "Kutan")) %>%
mutate(
kutancolor = case_when(
kutans == FALSE ~ lang_color,
TRUE ~ "white"))
vill_meta_kutans$lang <- factor(vill_meta_kutans$lang, levels =c(
"Dargwa", "Lak", "Bats", "Ingush", "Chechen", "Khinalug", "Archi", "Tsakhur", "Rutul", "Kryz", "Budukh", "Udi", "Lezgian", "Agul", "Tabasaran", "Avar", "Andi", "Botlikh", "Godoberi", "Chamalal", "Bagvalal", "Tindi", "Karata", "Akhvakh", "Tsez", "Hinuq", "Bezhta", "Hunzib", "Khwarshi", "Nogai", "Kumyk", "Azerbaijani", "Armenian", "Tat", "Georgian", "Kutan"))
# draw map
map.feature(lang.gltc(vill_meta_kutans$glottocode),
latitude = vill_meta_kutans$lat,
longitude = vill_meta_kutans$lon,
features = vill_meta_kutans$kutanlang,
color = vill_meta_kutans$kutancolor,
label = vill_meta_kutans$lang,
zoom.control = T,
popup = vill_meta_kutans$village,
tile = c("Esri.WorldTopoMap"))
```
## No kutans
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width = 9.5, fig.height= 7.5}
vill_meta_nokutans <- vill_meta[(vill_meta$kutans == FALSE),]
vill_meta_nokutans$lang <- factor(vill_meta_nokutans$lang, levels =c(
"Dargwa", "Lak", "Bats", "Ingush", "Chechen", "Khinalug", "Archi", "Tsakhur", "Rutul", "Kryz", "Budukh", "Udi", "Lezgian", "Agul", "Tabasaran", "Avar", "Andi", "Botlikh", "Godoberi", "Chamalal", "Bagvalal", "Tindi", "Karata", "Akhvakh", "Tsez", "Hinuq", "Bezhta", "Hunzib", "Khwarshi", "Nogai", "Kumyk", "Azerbaijani", "Tat", "Georgian"))
map.feature(lang.gltc(vill_meta_nokutans$glottocode),
latitude = vill_meta_nokutans$lat,
longitude = vill_meta_nokutans$lon,
features = vill_meta_nokutans$lang,
color = vill_meta_nokutans$lang_color,
label = vill_meta_nokutans$lang,
zoom.control = T,
popup = vill_meta_nokutans$village,
tile = c("Esri.WorldTopoMap"))
```