-
Notifications
You must be signed in to change notification settings - Fork 7
/
16_island.R
97 lines (86 loc) · 2.1 KB
/
16_island.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
# #30DayMapChallenge
# Día 16: Isla
# Rapa Nui
# Fuente datos: https://wikitravel.org/upload/shared//thumb/2/2c/Easter_Island_map.png/600px-Easter_Island_map.png
# Autora: Stephanie Orellana (@sporella)
library(sf)
library(ggplot2)
library(ggmap)
library(ggimage)
library(ggrepel)
library(cowplot)
library(magick)
library(extrafont)
loadfonts()
isla <- read_sf("data/rapanui.geojson")
moais <- read_sf("data/ahu_moais.geojson")
# Obtener mapa base -------------------------------------------------------
bb <- st_bbox(isla) + c(-0.001, -0.03, +0.001, +0.03)
names(bb) <- c("left", "bottom", "right", "top")
basemap <-
get_stamenmap(
bb,
zoom = 13,
maptype = "watercolor",
force = T,
color = "color"
)
img <- "img/moai.png"
# Visualización -----------------------------------------------------------
p <- ggmap(basemap, darken = c(0.6, "lavender")) +
geom_image(
data = moais,
aes(image = img, geometry = geometry),
stat = "sf_coordinates",
inherit.aes = F,
size = 0.04
) +
geom_text_repel(
data = moais,
aes(label = name, geometry = geometry),
stat = "sf_coordinates",
seed = 300,
nudge_x = 0.001,
segment.size = 0.3,
size = 2,
inherit.aes = F,
colour = "brown",
family = "Tempus Sans ITC",
fontface = "bold",
) +
labs(title = "RAPA NUI", caption = "@sporella") +
theme_nothing() +
theme(
plot.title = element_text(
family = "Tempus Sans ITC",
size = 30,
margin = margin(-40, 0, 0, 0),
hjust = 0.5,
vjust = -3,
colour = "brown"
),
plot.margin = margin(0, 0, 0, 0),
plot.caption = element_text(
size = 5,
margin = margin(-10, 0, 0, 0),
hjust = 0.99,
colour = "brown"
)
) +
coord_sf()
norte <- image_colorize(image_read("img/norte.png"),
opacity = 90,
color = "lightcyan2")
p2 <- ggdraw() +
draw_plot(p) +
draw_image(norte,
x = 0.2,
y = -0.3,
scale = .3)
ggsave(
filename = "plots/16_rapanui.png",
plot = p2,
width = 6,
height = 6,
bg = "lavender"
)