library(tidyverse)
library(maptools)
data(wrld_simpl)
#unique(wrld_simpl$ISO3)
plot(wrld_simpl %>% subset(., ISO3 %in% c("ALA")))
Overview
The Isole Åland
belonged to the provinces that the Swedish Empire had to cede to the Russian Empire with the Treaty of Fredrikshamn in September 1809, and became part of the semi-autonomous Grand Duchy of Finland
This is the reference for identifying ISO3 codes: ISO3 reference
We need wrld_simpl
for the shapefiles:
<- wrld_simpl$ISO3[wrld_simpl$ISO3=="ALA"]
ala<- fortify(wrld_simpl, region = 'ISO3')
shape_df
%>%
shape_dffilter(id=="ALA")%>%count(group)
<- shape_df%>%
shape_shortfilter(id=="ALA")%>%
mutate(group_names=case_when(group=="ALA.1"~"Åland",
=="ALA.2"~"Lemland",
group=="ALA.3"~"Eckero",
group=="ALA.4"~"Lumparland",
group=="ALA.5"~"Vardo")) group
made with ggplot2:
library(extrafont)
loadfonts()
fonts()
<- "Arial Rounded MT Bold"
family
<- ggplot() +
ala_pol_map geom_polygon(data =shape_short , aes(x = long, y = lat, group = group_names,
fill = group_names), color = 'black') +
geom_point(aes(x=19.944444, y=60.098611),color="darkred",size=4)+
ggtitle(label = " ")+
scale_fill_viridis_d()+
guides(fill=guide_legend(title.position ="top"))+
labs(fill="",
captions="\n#30DayMapChallenge Day3 Polygons\n\nDatasource: wrld_simpl {maptools} - Infographics: Federica Gazzelloni\n")+
::theme_map()+
ggthemestheme(text = element_text(family=family),
legend.text = element_text(family=family,size=14),
legend.direction = "vertical",
legend.background = element_blank(),
legend.key = element_rect(size=3),
plot.caption = element_text(hjust=0.5,vjust=2,size=11,colour = "black",family=family),
plot.title = element_text(size=34,vjust=1),
plot.title.position = "panel",
plot.background = element_rect(fill=NA, color=NA, size=20)
)
# final touches
library(cowplot)
library(magick)
<- magick::image_read(here::here("day3_polygons/capitol.png"))
image
<- cowplot::ggdraw(ala_pol_map)+
final draw_image(image,x = 0.8, y = 0.38,width = 0.1)+
draw_label(label="Mariehamn",x=0.3,y=0.2, fontfamily = family) +
draw_label(label="Polygons - Åland Islands",x=0.3,y=0.95, fontfamily = family,size=40) +
draw_line(x = c(0.345, 0.467),y = c(0.2, 0.385),color = "darkred", size = 0.5)
# save final plot
::agg_png("/Users/federica/Documents/R/R_general_resources/30DayMapChallenge/day3_polygons/polygons.png",
raggres = 320, width = 12, height = 8, units = "in")
finaldev.off()