-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path3_polygons.R
58 lines (49 loc) · 1.93 KB
/
3_polygons.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
# #30DayMapChallenge
# Día 3: polígonos
# Carta de Inundación por Tsunami
# Datos: http://www.geoportal.cl/geoportal/catalog/search/resource/resumen.page?uuid=%7B5FA8762F-DFAB-4CC7-9155-CC2012D7BF8A%7D
# Autora: Stephanie Orellana (@sporella)
library(sf)
library(tidyverse)
library(ggmap)
# Cargar y procesar datos -------------------------------------------------
tsu <- read_sf("data/tsunami_pichidangui.geojson") %>%
mutate(lab = str_replace(Name, "Profundidad de la inundación: ", ""))
mar <- read_sf("data/mar.geojson")
# Obtener mapa base -------------------------------------------------------
bb <- st_bbox(tsu)
names(bb) <- c("left", "bottom", "right", "top")
basemap <- get_stamenmap(bb, zoom = 14, maptype = "toner-lite", force = T, color = "color")
# Visualización -----------------------------------------------------------
p <- ggmap(basemap, darken = c(0.2, "palegoldenrod"))+
geom_sf(data = mar, inherit.aes = FALSE, fill = "lightcyan")+
geom_sf(data = tsu, aes(fill = lab), inherit.aes = FALSE, alpha = 0.6, size = 0.1) +
scale_fill_viridis_d(option = "D", direction = -1)+
labs(
fill = toupper("Profundidad de la Inundación"),
x = "",
y = "",
title = toupper("Carta de Inundación por Tsunami"),
subtitle = toupper("Pichidangui, Chile"),
caption = "@sporella"
) +
theme(
legend.justification = "bottom",
plot.caption.position = "plot",
panel.background = element_rect(fill = NA),
panel.grid = element_line(size = 0.3),
panel.ontop = TRUE,
axis.text = element_text(size = 6),
text = element_text(face = "bold")
) +
guides(
fill = guide_legend(
label.position = "bottom",
title.position = "left",
title.theme = element_text(angle = 90, size = 7, face="bold"),
keywidth = unit(2, "mm"),
keyheight = unit(3, "mm"),
override.aes = list(size = 1)
)
)
ggsave("plots/3_tsunami.png", plot = p, device = "png", width = 6, height = 6)