13  Human geography lab 4

pacman::p_load(tidyverse, rnaturalearth, sf)
global_map <- ne_countries(scale = "small", returnclass = "sf")
names(global_map)
  [1] "featurecla" "scalerank"  "labelrank"  "sovereignt" "sov_a3"    
  [6] "adm0_dif"   "level"      "type"       "tlc"        "admin"     
 [11] "adm0_a3"    "geou_dif"   "geounit"    "gu_a3"      "su_dif"    
 [16] "subunit"    "su_a3"      "brk_diff"   "name"       "name_long" 
 [21] "brk_a3"     "brk_name"   "brk_group"  "abbrev"     "postal"    
 [26] "formal_en"  "formal_fr"  "name_ciawf" "note_adm0"  "note_brk"  
 [31] "name_sort"  "name_alt"   "mapcolor7"  "mapcolor8"  "mapcolor9" 
 [36] "mapcolor13" "pop_est"    "pop_rank"   "pop_year"   "gdp_md"    
 [41] "gdp_year"   "economy"    "income_grp" "fips_10"    "iso_a2"    
 [46] "iso_a2_eh"  "iso_a3"     "iso_a3_eh"  "iso_n3"     "iso_n3_eh" 
 [51] "un_a3"      "wb_a2"      "wb_a3"      "woe_id"     "woe_id_eh" 
 [56] "woe_note"   "adm0_iso"   "adm0_diff"  "adm0_tlc"   "adm0_a3_us"
 [61] "adm0_a3_fr" "adm0_a3_ru" "adm0_a3_es" "adm0_a3_cn" "adm0_a3_tw"
 [66] "adm0_a3_in" "adm0_a3_np" "adm0_a3_pk" "adm0_a3_de" "adm0_a3_gb"
 [71] "adm0_a3_br" "adm0_a3_il" "adm0_a3_ps" "adm0_a3_sa" "adm0_a3_eg"
 [76] "adm0_a3_ma" "adm0_a3_pt" "adm0_a3_ar" "adm0_a3_jp" "adm0_a3_ko"
 [81] "adm0_a3_vn" "adm0_a3_tr" "adm0_a3_id" "adm0_a3_pl" "adm0_a3_gr"
 [86] "adm0_a3_it" "adm0_a3_nl" "adm0_a3_se" "adm0_a3_bd" "adm0_a3_ua"
 [91] "adm0_a3_un" "adm0_a3_wb" "continent"  "region_un"  "subregion" 
 [96] "region_wb"  "name_len"   "long_len"   "abbrev_len" "tiny"      
[101] "homepart"   "min_zoom"   "min_label"  "max_label"  "label_x"   
[106] "label_y"    "ne_id"      "wikidataid" "name_ar"    "name_bn"   
[111] "name_de"    "name_en"    "name_es"    "name_fa"    "name_fr"   
[116] "name_el"    "name_he"    "name_hi"    "name_hu"    "name_id"   
[121] "name_it"    "name_ja"    "name_ko"    "name_nl"    "name_pl"   
[126] "name_pt"    "name_ru"    "name_sv"    "name_tr"    "name_uk"   
[131] "name_ur"    "name_vi"    "name_zh"    "name_zht"   "fclass_iso"
[136] "tlc_diff"   "fclass_tlc" "fclass_us"  "fclass_fr"  "fclass_ru" 
[141] "fclass_es"  "fclass_cn"  "fclass_tw"  "fclass_in"  "fclass_np" 
[146] "fclass_pk"  "fclass_de"  "fclass_gb"  "fclass_br"  "fclass_il" 
[151] "fclass_ps"  "fclass_sa"  "fclass_eg"  "fclass_ma"  "fclass_pt" 
[156] "fclass_ar"  "fclass_jp"  "fclass_ko"  "fclass_vn"  "fclass_tr" 
[161] "fclass_id"  "fclass_pl"  "fclass_gr"  "fclass_it"  "fclass_nl" 
[166] "fclass_se"  "fclass_bd"  "fclass_ua"  "geometry"  
global_map %>% 
select(sovereignt, gdp_md, gdp_year) %>% 
DT::datatable()

pop_est: Contains a population estimate for the country

continent: The country’s continent

name_en: The country’s name in English

iso_a3: The country’s 3 letter abbreviation (we made this the index)

gdp_md: A country’s GDP in million dollar

geometry: A POLYGON for each country (we will learn more about these soon)

class(global_map)
[1] "sf"         "data.frame"

13.1 Global GDP map

global_map %>% 
  ggplot() +
  geom_sf(aes(fill = gdp_md)) +
  scale_fill_gradient(low = "white", high = "green") +
  labs(fill = "GDP") +
  theme_minimal(base_family = "HiraKakuProN-W3") +
  theme(legend.position = "bottom")

  • Let’s change the color and the position of legend.
global_map %>% 
  ggplot() +
  geom_sf(aes(fill = gdp_md)) +
  scale_fill_gradient(low = "gray", high = "blue") +
  labs(fill = "GDP_2019") +
  theme_minimal(base_family = "HiraKakuProN-W3") +
  theme(legend.position = "left")

13.2 Regional GDP map

  • GDP of European countries in 2019
global_map %>% 
  ggplot() +
  geom_sf(aes(fill = gdp_md)) +
  scale_fill_gradient(low = "white", high = "green") +
  labs(fill = "GDP_Europe") +
  coord_sf(xlim = c(-10, 45), ylim = c(35, 60)) +
  theme_minimal(base_family = "HiraKakuProN-W3") +
  theme(legend.position = "left")

  • GDP of African countries in 2019
global_map %>% 
  ggplot() +
  geom_sf(aes(fill = gdp_md)) +
  scale_fill_gradient(low = "white", high = "green") +
  labs(fill = "GDP_Africa") +
  coord_sf(xlim = c(-30, 60), ylim = c(-40, 40)) +
  theme_minimal(base_family = "HiraKakuProN-W3") +
  theme(legend.position = "left")