-
Notifications
You must be signed in to change notification settings - Fork 0
/
palaeomap_presentation.Rmd
277 lines (217 loc) · 6.77 KB
/
palaeomap_presentation.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
---
title: "Plotting Palaeogeographical Maps in R: an Example"
author: Ben M
date: 2021-03-11
fig_caption: true
output: beamer_presentation
---
# Plotting Palaeogeographical Maps in R
- Run in the cloud on Binder: <https://bit.ly/2N86wYf>
- _OR_
- Download code from GitHub: <https://bit.ly/38tBH7U>
# Palaeogeographical Maps
>- Hand made maps are a drag
>- Deep Time Maps (<https://deeptimemaps.com>)
>- Paleomap Project (<http://scotese.com>)
***
**GPlates** (<https://www.gplates.org/>) reconstructs palaeogeography at arbitrary
time.
# Automatic map plotting
>- NonaR/paleoMap (<https://github.com/NonaR/paleoMap>)
>- LunaSare/gplatesr (<https://github.com/LunaSare/gplatesr>)
```{r setup, echo = FALSE}
library(broom)
library(ggthemes)
library(mapproj)
library(rgdal)
library(tidyverse)
list.files("functions/", full.names = TRUE, pattern = "\\.R") %>%
walk(source)
```
# GPlates Web Service
- <https://gws.gplates.org/>
```{r gws_data, eval = FALSE}
coastline_gws_url <-
"http://gws.gplates.org/reconstruct/coastlines/?time=155&model=GOLONKA"
polygons_gws_url <-
"http://gws.gplates.org/reconstruct/static_polygons/?time=155&model=GOLONKA"
kimmeridgian_coastlines <-
rgdal::readOGR(coastline_gws_url) %>%
broom::tidy()
kimmeridgian_polygons <-
rgdal::readOGR(polygons_gws_url) %>%
broom::tidy()
```
***
```{r gws_plot, echo = FALSE, fig.width = 7, fig.height = 4, fig.cap = "**Outlines of continental plates in the Kimmeridgian (155 Ma).** Data downloaded from the GPlates web service.", warning = FALSE, message = FALSE, results = "hide"}
kimmeridgian_coastlines <-
readOGR(
"data/GWS/Matthews_etal_GPG_2016_Coastlines_reconstructed_155.00Ma.gmt"
) %>%
tidy()
kimmeridgian_polygons <-
readOGR(
"data/GWS/Matthews_etal_GPG_2016_Polygons_reconstructed_155.00Ma.gmt"
) %>%
tidy()
ggplot() +
geom_map(
data = kimmeridgian_polygons,
map = kimmeridgian_polygons,
aes(x = long, y = lat, map_id = id),
fill = "#D8D8D8"
) +
geom_map(
data = kimmeridgian_coastlines,
map = kimmeridgian_coastlines,
aes(x = long, y = lat, map_id = id),
colour = "#222222", fill = NA, size = 0.3
) +
coord_map("mollweide") +
map_border() +
theme_map()
```
# 'True' Palaeogeographical Outlines
GPlates web service gives:
>- outlines of plates from the model
>- modern coastline outlines
>- I want _ancient coastal outlines_ instead
***
- GPlates software has more models
- Including Cao et al. (2017) palaeogeographical reconstructions
```{r map_layers}
map_layers <-
c(
"Land" = "#FFD23A",
"Mountain" = "#FF8D51",
"Shallow marine" = "#45D8FF"
)
```
# Method
1. Load data into GPlates
2. Export for desired
3. Load into R and plot
```{r read_polygon_data, include = FALSE}
polygon_data <-
list.files("data/palaeogeography/", pattern = ".gmt", full.names = TRUE) %>%
map(readOGR) %>%
map(tidy) %>%
map2(
names(map_layers),
~ add_column(.x, geog_layer = .y)
) %>%
bind_rows() %>%
mutate(
polygon_id = str_c(id, group, geog_layer) %>% as_factor(),
geog_layer = factor(geog_layer, labels = names(map_layers))
)
```
***
But showing the separate layers (land, mountain, shallow marine, ice) doesn't
work easily with `geom_map`.
- have to add a new geom for every layer:
```{r multiple_geom_map, eval = FALSE}
ggplot() +
geom_map() +
geom_map() +
geom_map() + …
```
***
Instead I assign names to the layers (land, mountain…) and use `geom_polygon` to
plot.
NB:
- The data has 'groups' and 'subgroups' to close off the polygons, otherwise
shapes may cross the whole globe.
- Layers must be plot in order be marine > land > mountain > ice – use factors.
```{r rearrange_polygon_labels, include = FALSE}
id_level_order <-
map_layers[c(3, 1, 2)] %>%
map(
function(layr) polygon_data$polygon_id %>% levels() %>% str_which(layr)
) %>%
unlist()
polygon_data <-
polygon_data %>%
mutate(
polygon_id = fct_relevel(polygon_id, levels(polygon_id)[id_level_order])
)
```
***
```{r plot_base_map, fig.width = 7, fig.height = 4, fig.cap = "**Palaeogeography in the Kimmeridgian (155 Ma).**", echo = FALSE}
# dev.new(width = 7, height = 4)
map_plot <-
ggplot() +
geom_polygon(
data = polygon_data,
aes(
x = long,
y = lat,
fill = geog_layer,
colour = geog_layer,
group = polygon_id
),
) +
coord_map("mollweide") +
theme_map() +
palaeogeog_map_niceties()
map_plot
```
***
I also wanted to add coastlines to show where modern countries are, but not the
full plates from the web service.
>- use coastlines reconstructed polylines
```{r read_coastline_polygons, echo = FALSE, results = "hide"}
modern_coastlines <-
readOGR("data/coastlines/Matthews_etal_GPC_2016_Coastlines_Polyline_reconstructed_155.00Ma.gmt") %>%
tidy() %>%
add_column(geog_layer = "Modern coastlines") %>%
mutate(polygon_id = str_c(id, group, geog_layer) %>% as_factor())
```
***
```{r plot_coast_outlines, fig.width = 7, fig.height = 4, fig.cap = "**Palaeogeography in the Kimmeridgian (155 Ma).** Outlines of modern coastlines (where known) are included in grey.", echo = FALSE}
map_plot +
geom_path(
data = modern_coastlines,
aes(
x = long,
y = lat,
group = polygon_id,
),
colour = "#888888", size = 0.3
)
```
# Add Fossil Occurrences
Now to add some fossil occurrences.
Of course it's ichthyosaurs, because I have no imagination:
- Callovian–Tithonian (166-145 Ma)
- all levels, taxonomy – no filtering
```{r download_pbdb_data, eval = FALSE}
pbdb_url <-
"https://paleobiodb.org/data1.2/occs/list.csv?base_name=Ichthyosauromorpha&interval=Callovian,Oxfordian,Kimmeridgian,Tithonian&show=paleoloc"
occ_ichthyosaurs <-
read_csv(pbdb_url)
```
Use `geom_point` to overlay this on the base map.
```{r read_ichthyosaur_occurrences, echo = FALSE, results = "hide", warning = FALSE, message = FALSE}
occ_ichthyosaurs <-
read_csv("data/occurrences/2021-02-18-ichthyosaur-occurrences.csv")
```
***
```{r plot_occurrences, fig.height = 4, fig.width = 7, fig.cap = "**Occurrences of ichthyosaurs from the Callovian–Tithonian.** Palaeogeographical map shows the distribution of land in the Kimmeridgian (155 Ma).", echo = FALSE, warning = FALSE}
occ_plot <-
map_plot +
geom_point(
data = occ_ichthyosaurs,
aes(
x = paleolng,
y = paleolat
)
)
occ_plot
```
***
These plots can also be split automagically using _facets._
```{r facet_plot, fig.width = 7, fig.height = 4, fig.cap = "**Occurrences of ichthyosaurs in the Callovian–Tithonia separated by identified rank.** Palaeogeographical maps shows distribution of land in the Kimmeridgian (155 Ma).", echo = FALSE, warning = FALSE}
occ_plot +
facet_wrap(vars(accepted_rank))
```