-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_run_sauri.R
448 lines (411 loc) · 18 KB
/
_run_sauri.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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
outDir = "C:/Rprojects/sauri/doc/"
# read
source("R/roques_read.R")
source("R/gravats_read.R")
roques <- roques_read(roques = "C:/Rprojects/sauri/doc/data/sources/240415/Thomas_Sauri.gpkg",
gpkg.layer = "Roques")
gravats <- gravats_read(gravats = "C:/Rprojects/sauri/doc/data/sources/240415/llista_gravats_19-20-23_DEFINITIVA_FINAL_FINAL_1.xlsx")
############# Engraved rocks x Engravings #####################################
# Stats per roques: número de grabados por roca, altitudes, etc.
source("R/roques_x_gravats.R")
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
stats = "altis_tema_att")
# ggplot2::ggsave(paste0(outDir, "_distr_typogravats_x_altura_thm.png"), lg$altis_tema_att, width = 21, height = 14, units = "cm")
# ggplot2::ggsave(paste0(outDir, "_distr_nbgravats_x_nbroques.png"), lg$ngrav, width = 16, height = 8, units = "cm")
# ggplot2::ggsave(paste0(outDir, "_distr_nbgravats_x_altura.png"), lg$altis_ngrav, width = 16, height = 10, units = "cm")
# ggplot2::ggsave(paste0(outDir, "_distr_typogravats_x_altura.png"), lg$altis_tema, width = 21, height = 18, units = "cm")
# Spatial
source("R/roques_x_gravats.R")
lthms <- list(# ico
# thm_cavalier = c("thm", "A.?h"),
# thm_arbaletrier = c("thm", "A.?b"),
# thm_cheval = c("thm", "Z.?h"),
# thm_oiseau = c("thm", "Z.?b"),
# thm_fleche = c("thm", "T.?f"),
# thm_arbalete = c("thm", "T.?b"),
# thm_cornemuse = c("thm", "T.?m"),
# thm_pentacle = c("thm", "G.?p"),
# thm_croix_chretienne = c("thm", "G.?k"),
# thm_ecritures = c("thm", "^L"),
thm_genet = c("thm_xt", "personatge.*cavall"),
thm_balleste = c("thm_xt", "personatge.*ballesta"),
thm_cavall = c("thm_xt", "zoomorf.*èquid"),
thm_ocell= c("thm_xt", "zoomorf.*ocell"),
thm_fletxa = c("thm_xt", "tècnic.*fletxa"),
thm_ballesta = c("thm_xt", "tècnic.*ballesta"),
thm_cornamusa = c("thm_xt", "tècnic.*cornamusa"),
thm_pentacle = c("thm_xt", "geomètric.*pentacle"),
thm_creu_cristiana = c("thm_xt", "geomètric.*creu cristiana"),
thm_escriptura = c("thm_xt", "literal"),
tec_naviforme = c("tec", ".*n.*"),
lat_dreta = c("lat", "->"),
lat_esquerra = c("lat", "<-")
)
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
lthms = lthms)
# ggplot2::ggsave(paste0(outDir, "_spat_typogravats_1.png"), lg$spats_tema, width = 21, height = length(lthms)*3, units = "cm")
############# Engraved rocks #####################################
source("R/roques_desc.R")
lg <- roques_desc(roques = roques)
# lg$map_leaflet
htmlwidgets::saveWidget(lg$map_leaflet, "C:/Rprojects/sauri/doc/map_leaflet.html", title = "Sauri - roques")
lg$list_ordered
############# Engravings #####################################
## Descriptive
source("R/gravats_desc.R")
lg <- gravats_desc(gravats = gravats, stats = 'thm')
lg <- gravats_desc(gravats = gravats, stats = 'tec')
# ggplot2::ggsave(paste0(outDir, "_spat_typogravats.png"), lg$grav_tec, width = 14, height = 14, units = "cm")
########## level 1 ###############
## Multifact
lthms <- list(# ico
# anthropomorph
thm_home = c("thm_xt", "personatge.*home"),
thm_dona = c("thm_xt", "personatge.*dona"),
thm_genet = c("thm_xt", "personatge.*cavall"),
thm_ballester = c("thm_xt", "personatge.*ballesta"),
thm_casc_barret_corona = c("thm_xt", "personatge.*casc/barret/corona"),
# technomorph
thm_lanca = c("thm_xt", "personatge.*llança"),
thm_espasa = c("thm_xt", "personatge.*espasa"),
thm_arc = c("thm_xt", "personatge.*arc"),
thm_fletxa = c("thm_xt", "tècnic.*fletxa"),
thm_ballesta = c("thm_xt", "tècnic.*ballesta"),
thm_cornamusa = c("thm_xt", "tècnic.*cornamusa"),
# zoomorph
thm_cavall = c("thm_xt", "zoomorf.*cavall"),
# thm_cavall_equid = c("thm_xt", "zoomorf.*(?=.*èquid)(?=.*cavall)"), # TODO
thm_ocell= c("thm_xt", "zoomorf.*ocell"),
# geometric
thm_arboriforme = c("thm_xt", "geomètric.*arboriforme"),
thm_pentacle = c("thm_xt", "geomètric.*pentacle"),
thm_estrella = c("thm_xt", "geomètric.*estrella"),
thm_zigzag = c("thm_xt", "geomètric.*zig-zag"),
thm_creu_cristiana = c("thm_xt", "geomètric.*creu cristiana"),
# writings
thm_escriptura = c("thm_xt", "literal")
# engraving technique
# tec_naviforme = c("tec", ".*n.*")
# lat_dreta = c("lat", "->"),
# lat_esquerra = c("lat", "<-")
)
# source("R/gravats_multi.R")
# lg <- gravats_multi(gravats = gravats,
# stats = "sd",
# lthms = lthms)
source("R/gravats_multi.R")
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3)
# ggplot2::ggsave(paste0(outDir, "gthms_1_ca.png"), lg$mult_ca_plot, width = 15, height = 15, units = "cm")
## Not Run
# lg$mult_ca_stat$eig # Eigen values
# paste0(rownames(lg$mult_ca_stat$col$coord), collapse = ", ") # studied themes
## Draw boxes
source("R/dum_box.R")
lbox <- list(list("fletxa", c(-3.1, -1.7, 0, 1)), #
list("escriptura", c(0, 1, 3.5, 5)), #
list("others", c(-1.5, 1, -1, 2)) #
) # ,
gthms_1_box <- dum_box(gplot = lg$mult_ca_plot,
lbox = lbox)
ggplot2::ggsave(paste0(outDir, "gthms_1_ca_box.png"), gthms_1_box, width = 15, height = 15, units = "cm")
# Export separate boxes
# source("R/gravats_multi.R")
# lg <- gravats_multi(gravats = gravats,
# lthms = lthms,
# pts.size = 2,
# lbl.size = 3,
# ind.lbl.shw = TRUE,
# limit.coords = lbox[[i]][[2]])
#
# # Export separate boxes
# source("R/gravats_multi.R")
# lg <- gravats_multi(gravats = gravats,
# lthms = lthms,
# pts.size = 2,
# lbl.size = 3,
# ind.lbl.shw = TRUE,
# limit.coords = lbox[[i]][[2]])
# # lg$mult_ca_plot
source("R/roques_x_gravats.R")
# title.adds <- c("zigzag_and_arboriforme", "estrealla_and_creuChris_and_pentacle")
for(i in 1:(length(lbox)-1)){
# avoid others
# limit to some individuals to spot a particular spatial distribution
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3,
ind.lbl.shw = TRUE,
limit.coords = lbox[[i]][[2]])
ggplot2::ggsave(paste0(outDir, "gthms_1_ca_", lbox[[i]][[1]],".png"), lg$mult_ca_plot,
width = 11, height = 11, units = "cm")
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
limit_ind = as.character(lg$mult_ca_limit_ind$roques),
stats = "spats_limit_ind",
title.add = lbox[[i]][[1]])
# Spatial distribution of selected rocks
ggplot2::ggsave(paste0(outDir, "gthms_1_spat_", lbox[[i]][[1]],".png"), lg$spats_limit_ind,
width = 11, height = 11, units = "cm")
}
########## level 2 ###############
# without fletxa and escrituras
source("R/gravats_multi.R")
lthms <- list(# ico
# anthropomorph
thm_home = c("thm_xt", "personatge.*home"),
thm_dona = c("thm_xt", "personatge.*dona"),
thm_genet = c("thm_xt", "personatge.*cavall"),
thm_ballester = c("thm_xt", "personatge.*ballesta"),
thm_casc_barret_corona = c("thm_xt", "personatge.*casc/barret/corona"),
# technomorph
thm_lanca = c("thm_xt", "personatge.*llança"),
thm_espasa = c("thm_xt", "personatge.*espasa"),
thm_arc = c("thm_xt", "personatge.*arc"),
thm_ballesta = c("thm_xt", "tècnic.*ballesta"),
thm_cornamusa = c("thm_xt", "tècnic.*cornamusa"),
# zoomorph
thm_cavall = c("thm_xt", "zoomorf.*cavall"),
# thm_cavall_equid = c("thm_xt", "zoomorf.*(?=.*èquid)(?=.*cavall)"), # TODO
thm_ocell= c("thm_xt", "zoomorf.*ocell"),
# geometric
thm_arboriforme = c("thm_xt", "geomètric.*arboriforme"),
thm_pentacle = c("thm_xt", "geomètric.*pentacle"),
thm_estrella = c("thm_xt", "geomètric.*estrella"),
thm_zigzag = c("thm_xt", "geomètric.*zig-zag"),
thm_creu_cristiana = c("thm_xt", "geomètric.*creu cristiana")
)
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3)
ggplot2::ggsave(paste0(outDir, "gthms_2_ca.png"), lg$mult_ca_plot, width = 15, height = 15, units = "cm")
## Multifact + boxes
source("R/dum_box.R")
# lbox <- list(c(1.2, 3, 0.5, 2.5), # zigzag and arboriforme
# c(0, 2, -2, -.5), # creu_chritsiana estrell pentacle
# c(-1.5, .5, -.5, 1) # other
# ) # ,
lbox <- list(list("zigzag_and_arboriforme", c(1.2, 2.8, 0.5, 2.2)), # zigzag and arboriforme
list("creu_chritsiana_and_estrell_and_pentacle", c(0, 1.8, -2, -.5)), #
list("others", c(-1.2, .5, -.5, 1)) # o
) # ,
# Draw boxes
gthms_2 <- dum_box(gplot = lg$mult_ca_plot,
lbox = lbox)
ggplot2::ggsave(paste0(outDir, "gthms_2_ca_box.png"), gthms_2, width = 15, height = 15, units = "cm")
# Export separate boxes
source("R/gravats_multi.R")
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3,
ind.lbl.shw = TRUE,
limit.coords = lbox[[i]][[2]])
# lg$mult_ca_plot
# Spatial distribution of selected rocks
source("R/roques_x_gravats.R")
# title.adds <- c("zigzag_and_arboriforme", "estrealla_and_creuChris_and_pentacle")
for(i in 1:(length(lbox)-1)){
# avoid others
# limit to some individuals to spot a particular spatial distribution
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3,
ind.lbl.shw = TRUE,
limit.coords = lbox[[i]][[2]])
ggplot2::ggsave(paste0(outDir, "gthms_2_ca_", lbox[[i]][[1]],".png"), lg$mult_ca_plot,
width = 11, height = 11, units = "cm")
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
limit_ind = as.character(lg$mult_ca_limit_ind$roques),
stats = "spats_limit_ind",
title.add = lbox[[i]][[1]])
ggplot2::ggsave(paste0(outDir, "gthms_2_spat_", lbox[[i]][[1]],".png"), lg$spats_limit_ind,
width = 11, height = 11, units = "cm")
}
########## level 3 ###############
# without fletxa and escrituras and zigzag; and arboriforme and estrealla and creu cristiana and pentacle
source("R/gravats_multi.R")
lthms <- list(# ico
# anthropomorph
thm_home = c("thm_xt", "personatge.*home"),
thm_dona = c("thm_xt", "personatge.*dona"),
thm_genet = c("thm_xt", "personatge.*cavall"),
thm_ballester = c("thm_xt", "personatge.*ballesta"),
thm_casc_barret_corona = c("thm_xt", "personatge.*casc/barret/corona"),
# technomorph
thm_lanca = c("thm_xt", "personatge.*llança"),
thm_espasa = c("thm_xt", "personatge.*espasa"),
thm_arc = c("thm_xt", "personatge.*arc"),
thm_ballesta = c("thm_xt", "tècnic.*ballesta"),
thm_cornamusa = c("thm_xt", "tècnic.*cornamusa"),
# zoomorph
thm_cavall = c("thm_xt", "zoomorf.*cavall"),
# thm_cavall_equid = c("thm_xt", "zoomorf.*(?=.*èquid)(?=.*cavall)"), # TODO
thm_ocell= c("thm_xt", "zoomorf.*ocell")
)
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3)
ggplot2::ggsave(paste0(outDir, "gthms_3_ca.png"), lg$mult_ca_plot, width = 15, height = 15, units = "cm")
## Multifact + boxes
source("R/dum_box.R")
# lbox <- list(c(1.2, 3, 0.5, 2.5), # zigzag and arboriforme
# c(0, 2, -2, -.5), # creu_chritsiana estrell pentacle
# c(-1.5, .5, -.5, 1) # other
# ) # ,
lbox <- list(list("ballesta", c(.2, 1.5, -2.2, -1)), # zigzag and arboriforme
list("ocell_ballester", c(-2, -.5, -1.5, 0.2)), #
list("others", c(-.5, 1, -.5, 1.5)) # o
) # ,
# Draw boxes
gthms_3 <- dum_box(gplot = lg$mult_ca_plot,
lbox = lbox)
ggplot2::ggsave(paste0(outDir, "gthms_3_ca_box.png"), gthms_3, width = 15, height = 15, units = "cm")
# # Export separate boxes
# source("R/gravats_multi.R")
# lg <- gravats_multi(gravats = gravats,
# lthms = lthms,
# pts.size = 2,
# lbl.size = 3,
# ind.lbl.shw = TRUE,
# limit.coords = lbox[[i]][[2]])
# lg$mult_ca_plot
# Spatial distribution of selected rocks
source("R/roques_x_gravats.R")
for(i in 1:(length(lbox)-1)){
# avoid others
# limit to some individuals to spot a particular spatial distribution
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3,
ind.lbl.shw = TRUE,
limit.coords = lbox[[i]][[2]])
ggplot2::ggsave(paste0(outDir, "gthms_3_ca_", lbox[[i]][[1]],".png"), lg$mult_ca_plot,
width = 11, height = 11, units = "cm")
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
limit_ind = as.character(lg$mult_ca_limit_ind$roques),
stats = "spats_limit_ind",
title.add = lbox[[i]][[1]])
ggplot2::ggsave(paste0(outDir, "gthms_3_spat_", lbox[[i]][[1]],".png"), lg$spats_limit_ind,
width = 11, height = 11, units = "cm")
}
########## level 4 ###############
# without fletxa and escrituras and zigzag; and arboriforme and estrealla and creu cristiana and pentacle; ocell, ballesta, ballester
source("R/gravats_multi.R")
lthms <- list(# ico
# anthropomorph
thm_home = c("thm_xt", "personatge.*home"),
thm_dona = c("thm_xt", "personatge.*dona"),
thm_genet = c("thm_xt", "personatge.*cavall"),
thm_casc_barret_corona = c("thm_xt", "personatge.*casc/barret/corona"),
# technomorph
thm_lanca = c("thm_xt", "personatge.*llança"),
thm_espasa = c("thm_xt", "personatge.*espasa"),
thm_arc = c("thm_xt", "personatge.*arc"),
thm_cornamusa = c("thm_xt", "tècnic.*cornamusa"),
# zoomorph
thm_cavall = c("thm_xt", "zoomorf.*cavall")
# thm_cavall_equid = c("thm_xt", "zoomorf.*(?=.*èquid)(?=.*cavall)"), # TODO
)
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3)
ggplot2::ggsave(paste0(outDir, "gthms_4_ca.png"), lg$mult_ca_plot, width = 15, height = 15, units = "cm")
lg$mult_ca_stat$eig
## Multifact + boxes
source("R/dum_box.R")
lbox <- list(list("cavall", c(-2.7, -1.3, -.5, .5)), # zigzag and arboriforme
list("arc", c(.2, 1.6, 1.4, 6.4)), #
list("others", c(-.7, 1, -1, .8)) # o
)
# Draw boxes
gthms_4 <- dum_box(gplot = lg$mult_ca_plot,
lbox = lbox)
gthms_4
ggplot2::ggsave(paste0(outDir, "gthms_4_ca_box.png"), gthms_4, width = 15, height = 15, units = "cm")
source("R/roques_x_gravats.R")
# "length(lbox)-1" to avoid other, studied in the next level
for(i in 1:(length(lbox)-1)){
# CA by box
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3,
ind.lbl.shw = TRUE,
limit.coords = lbox[[i]][[2]])
ggplot2::ggsave(paste0(outDir, "gthms_4_ca_", lbox[[i]][[1]],".png"), lg$mult_ca_plot,
width = 11, height = 11, units = "cm")
# Spatial
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
limit_ind = as.character(lg$mult_ca_limit_ind$roques),
stats = "spats_limit_ind",
title.add = lbox[[i]][[1]])
ggplot2::ggsave(paste0(outDir, "gthms_4_spat_", lbox[[i]][[1]],".png"), lg$spats_limit_ind,
width = 11, height = 11, units = "cm")
}
########## level 5 ###############
# without fletxa and escrituras and zigzag; and arboriforme and estrealla and creu cristiana and pentacle; ocell, ballesta, ballester; arc, cavall
source("R/gravats_multi.R")
lthms <- list(# ico
# anthropomorph
thm_home = c("thm_xt", "personatge.*home"),
thm_dona = c("thm_xt", "personatge.*dona"),
thm_genet = c("thm_xt", "personatge.*cavall"),
thm_casc_barret_corona = c("thm_xt", "personatge.*casc/barret/corona"),
# technomorph
thm_lanca = c("thm_xt", "personatge.*llança"),
thm_espasa = c("thm_xt", "personatge.*espasa"),
thm_cornamusa = c("thm_xt", "tècnic.*cornamusa")
# thm_cavall_equid = c("thm_xt", "zoomorf.*(?=.*èquid)(?=.*cavall)"), # TODO
)
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3)
ggplot2::ggsave(paste0(outDir, "gthms_5_ca.png"), lg$mult_ca_plot, width = 15, height = 15, units = "cm")
lg$mult_ca_stat$eig
## Multifact + boxes
source("R/dum_box.R")
lbox <- list(list("dona", c(0, 1.5, 1.5, 5)), # zigzag and arboriforme
list("cornamusa", c(1.5, 5, -1.5, .5)), #
list("others", c(-1, .5, -1, 1)) # o
)
# Draw boxes
gthms_5 <- dum_box(gplot = lg$mult_ca_plot,
lbox = lbox)
gthms_5
ggplot2::ggsave(paste0(outDir, "gthms_5_ca_box.png"), gthms_5, width = 15, height = 15, units = "cm")
source("R/roques_x_gravats.R")
# "length(lbox)-1" to avoid other, studied in the next level
for(i in 1:(length(lbox)-1)){
# CA by box
lg <- gravats_multi(gravats = gravats,
lthms = lthms,
pts.size = 2,
lbl.size = 3,
ind.lbl.shw = TRUE,
limit.coords = lbox[[i]][[2]])
ggplot2::ggsave(paste0(outDir, "gthms_5_ca_", lbox[[i]][[1]],".png"), lg$mult_ca_plot,
width = 11, height = 11, units = "cm")
# Spatial
lg <- roques_x_gravats(roques = roques,
gravats = gravats,
limit_ind = as.character(lg$mult_ca_limit_ind$roques),
stats = "spats_limit_ind",
title.add = lbox[[i]][[1]])
ggplot2::ggsave(paste0(outDir, "gthms_5_spat_", lbox[[i]][[1]],".png"), lg$spats_limit_ind,
width = 11, height = 11, units = "cm")
}