class: center, middle, inverse, title-slide # Mapping Data in R with ggplot2 and geom_sf() ## a ‘flipbookr’ tutorial ### Gina Reynolds and Conner J. Surrency --- # What Are We Doing? -- - Here we will walk through the process of creating maps in with ggplot using geom_sf() -- - This will include the packages required and how to code a map. -- - We will be looking at data from two cases: Wetherspoon restaurants in UK, and life expectancy in europe --- ## Set-Up -- We will need the following packages (and data) installed: -- - tidyverse -- - rnaturalearth --- #Example #1 -- We know the location of restaurants in the UK and the price of the empire burgur. The map we make will be a simple static map that shows those points. --- count: false .left-panel-wetherspoon-auto[ ```r *library(tidyverse) ``` ] .right-panel-wetherspoon-auto[ ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) *library(rnaturalearth) ``` ] .right-panel-wetherspoon-auto[ ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) library(rnaturalearth) *library(readxl) ``` ] .right-panel-wetherspoon-auto[ ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) library(rnaturalearth) library(readxl) *read_excel("wetherspoon.xlsx") ``` ] .right-panel-wetherspoon-auto[ ``` # A tibble: 213 x 19 Name Location Latitude Longitude `Empire State B… `Chicken Tikka` <chr> <chr> <dbl> <dbl> <dbl> <dbl> 1 The … Leicest… 51.5 -0.129 11.2 8.39 2 The … Whiteha… 51.5 -0.127 11.0 8.39 3 Pend… Holborn… 51.5 -0.115 11.0 8.39 4 The … City of… 51.5 -0.0847 11.0 8.39 5 The … Manches… 53.5 -2.35 13.6 9.15 6 The … Windsor 51.5 -0.609 10.6 8.99 7 The … Beacons… 51.6 -0.627 9.75 8.99 8 Good… Tower H… 51.5 -0.0728 11.0 8.39 9 Cast… Manches… 53.5 -2.36 11.5 8.4 10 The … Camden,… 51.5 -0.145 11.2 8.39 # … with 203 more rows, and 13 more variables: `Gammon afternoon deal` <chr>, # `Chocolate Brownie` <dbl>, `Doom Bar` <dbl>, `Birra Moretti` <dbl>, `Porn # Star at 2 x £12` <chr>, `Porn Star (glass)` <chr>, MEAL <dbl>, Notes <chr>, # `Moretti as a % of a tikka` <dbl>, `Moretti as % of burger` <dbl>, `PRICE # BUCKETS` <chr>, `Food cost £` <dbl>, `Drink cost £` <dbl> ``` ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) library(rnaturalearth) library(readxl) read_excel("wetherspoon.xlsx") -> *wetherspoon_raw ``` ] .right-panel-wetherspoon-auto[ ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) library(rnaturalearth) library(readxl) read_excel("wetherspoon.xlsx") -> wetherspoon_raw *wetherspoon_raw ``` ] .right-panel-wetherspoon-auto[ ``` # A tibble: 213 x 19 Name Location Latitude Longitude `Empire State B… `Chicken Tikka` <chr> <chr> <dbl> <dbl> <dbl> <dbl> 1 The … Leicest… 51.5 -0.129 11.2 8.39 2 The … Whiteha… 51.5 -0.127 11.0 8.39 3 Pend… Holborn… 51.5 -0.115 11.0 8.39 4 The … City of… 51.5 -0.0847 11.0 8.39 5 The … Manches… 53.5 -2.35 13.6 9.15 6 The … Windsor 51.5 -0.609 10.6 8.99 7 The … Beacons… 51.6 -0.627 9.75 8.99 8 Good… Tower H… 51.5 -0.0728 11.0 8.39 9 Cast… Manches… 53.5 -2.36 11.5 8.4 10 The … Camden,… 51.5 -0.145 11.2 8.39 # … with 203 more rows, and 13 more variables: `Gammon afternoon deal` <chr>, # `Chocolate Brownie` <dbl>, `Doom Bar` <dbl>, `Birra Moretti` <dbl>, `Porn # Star at 2 x £12` <chr>, `Porn Star (glass)` <chr>, MEAL <dbl>, Notes <chr>, # `Moretti as a % of a tikka` <dbl>, `Moretti as % of burger` <dbl>, `PRICE # BUCKETS` <chr>, `Food cost £` <dbl>, `Drink cost £` <dbl> ``` ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) library(rnaturalearth) library(readxl) read_excel("wetherspoon.xlsx") -> wetherspoon_raw wetherspoon_raw %>% * janitor::clean_names() ``` ] .right-panel-wetherspoon-auto[ ``` # A tibble: 213 x 19 name location latitude longitude empire_state_bu… chicken_tikka <chr> <chr> <dbl> <dbl> <dbl> <dbl> 1 The … Leicest… 51.5 -0.129 11.2 8.39 2 The … Whiteha… 51.5 -0.127 11.0 8.39 3 Pend… Holborn… 51.5 -0.115 11.0 8.39 4 The … City of… 51.5 -0.0847 11.0 8.39 5 The … Manches… 53.5 -2.35 13.6 9.15 6 The … Windsor 51.5 -0.609 10.6 8.99 7 The … Beacons… 51.6 -0.627 9.75 8.99 8 Good… Tower H… 51.5 -0.0728 11.0 8.39 9 Cast… Manches… 53.5 -2.36 11.5 8.4 10 The … Camden,… 51.5 -0.145 11.2 8.39 # … with 203 more rows, and 13 more variables: gammon_afternoon_deal <chr>, # chocolate_brownie <dbl>, doom_bar <dbl>, birra_moretti <dbl>, # porn_star_at_2_x_12 <chr>, porn_star_glass <chr>, meal <dbl>, notes <chr>, # moretti_as_a_percent_of_a_tikka <dbl>, moretti_as_percent_of_burger <dbl>, # price_buckets <chr>, food_cost <dbl>, drink_cost <dbl> ``` ] --- count: false .left-panel-wetherspoon-auto[ ```r library(tidyverse) library(rnaturalearth) library(readxl) read_excel("wetherspoon.xlsx") -> wetherspoon_raw wetherspoon_raw %>% janitor::clean_names() -> *wetherspoon ``` ] .right-panel-wetherspoon-auto[ ] <style> .left-panel-wetherspoon-auto { color: #777; width: 38.6138613861386%; height: 92%; float: left; font-size: 80% } .right-panel-wetherspoon-auto { width: 59.4059405940594%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-wetherspoon-auto { width: 0%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .left-panel-wether-auto[ ```r *rnaturalearth::ne_countries( * scale = "medium", returnclass = "sf") ``` ] .right-panel-wether-auto[ ``` Simple feature collection with 241 features and 63 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 First 10 features: scalerank featurecla labelrank sovereignt sov_a3 adm0_dif 0 3 Admin-0 country 5 Netherlands NL1 1 1 1 Admin-0 country 3 Afghanistan AFG 0 2 1 Admin-0 country 3 Angola AGO 0 3 1 Admin-0 country 6 United Kingdom GB1 1 4 1 Admin-0 country 6 Albania ALB 0 5 3 Admin-0 country 6 Finland FI1 1 6 3 Admin-0 country 6 Andorra AND 0 7 1 Admin-0 country 4 United Arab Emirates ARE 0 8 1 Admin-0 country 2 Argentina ARG 0 9 1 Admin-0 country 6 Armenia ARM 0 level type admin adm0_a3 geou_dif 0 2 Country Aruba ABW 0 1 2 Sovereign country Afghanistan AFG 0 2 2 Sovereign country Angola AGO 0 3 2 Dependency Anguilla AIA 0 4 2 Sovereign country Albania ALB 0 5 2 Country Aland ALD 0 6 2 Sovereign country Andorra AND 0 7 2 Sovereign country United Arab Emirates ARE 0 8 2 Sovereign country Argentina ARG 0 9 2 Sovereign country Armenia ARM 0 geounit gu_a3 su_dif subunit su_a3 brk_diff 0 Aruba ABW 0 Aruba ABW 0 1 Afghanistan AFG 0 Afghanistan AFG 0 2 Angola AGO 0 Angola AGO 0 3 Anguilla AIA 0 Anguilla AIA 0 4 Albania ALB 0 Albania ALB 0 5 Aland ALD 0 Aland ALD 0 6 Andorra AND 0 Andorra AND 0 7 United Arab Emirates ARE 0 United Arab Emirates ARE 0 8 Argentina ARG 0 Argentina ARG 0 9 Armenia ARM 0 Armenia ARM 0 name name_long brk_a3 brk_name 0 Aruba Aruba ABW Aruba 1 Afghanistan Afghanistan AFG Afghanistan 2 Angola Angola AGO Angola 3 Anguilla Anguilla AIA Anguilla 4 Albania Albania ALB Albania 5 Aland Aland Islands ALD Aland 6 Andorra Andorra AND Andorra 7 United Arab Emirates United Arab Emirates ARE United Arab Emirates 8 Argentina Argentina ARG Argentina 9 Armenia Armenia ARM Armenia brk_group abbrev postal formal_en formal_fr note_adm0 0 <NA> Aruba AW Aruba <NA> Neth. 1 <NA> Afg. AF Islamic State of Afghanistan <NA> <NA> 2 <NA> Ang. AO People's Republic of Angola <NA> <NA> 3 <NA> Ang. AI <NA> <NA> U.K. 4 <NA> Alb. AL Republic of Albania <NA> <NA> 5 <NA> Aland AI Åland Islands <NA> Fin. 6 <NA> And. AND Principality of Andorra <NA> <NA> 7 <NA> U.A.E. AE United Arab Emirates <NA> <NA> 8 <NA> Arg. AR Argentine Republic <NA> <NA> 9 <NA> Arm. ARM Republic of Armenia <NA> <NA> note_brk name_sort name_alt mapcolor7 mapcolor8 mapcolor9 0 <NA> Aruba <NA> 4 2 2 1 <NA> Afghanistan <NA> 5 6 8 2 <NA> Angola <NA> 3 2 6 3 <NA> Anguilla <NA> 6 6 6 4 <NA> Albania <NA> 1 4 1 5 <NA> Aland <NA> 4 1 4 6 <NA> Andorra <NA> 1 4 1 7 <NA> United Arab Emirates <NA> 2 1 3 8 <NA> Argentina <NA> 3 1 3 9 <NA> Armenia <NA> 3 1 2 mapcolor13 pop_est gdp_md_est pop_year lastcensus gdp_year 0 9 103065 2258.0 NA 2010 NA 1 7 28400000 22270.0 NA 1979 NA 2 1 12799293 110300.0 NA 1970 NA 3 3 14436 108.9 NA NA NA 4 6 3639453 21810.0 NA 2001 NA 5 6 27153 1563.0 NA NA NA 6 8 83888 3660.0 NA 1989 NA 7 3 4798491 184300.0 NA 2010 NA 8 13 40913584 573900.0 NA 2010 NA 9 10 2967004 18770.0 NA 2001 NA economy income_grp wikipedia fips_10 iso_a2 0 6. Developing region 2. High income: nonOECD NA <NA> AW 1 7. Least developed region 5. Low income NA <NA> AF 2 7. Least developed region 3. Upper middle income NA <NA> AO 3 6. Developing region 3. Upper middle income NA <NA> AI 4 6. Developing region 4. Lower middle income NA <NA> AL 5 2. Developed region: nonG7 1. High income: OECD NA <NA> AX 6 2. Developed region: nonG7 2. High income: nonOECD NA <NA> AD 7 6. Developing region 2. High income: nonOECD NA <NA> AE 8 5. Emerging region: G20 3. Upper middle income NA <NA> AR 9 6. Developing region 4. Lower middle income NA <NA> AM iso_a3 iso_n3 un_a3 wb_a2 wb_a3 woe_id adm0_a3_is adm0_a3_us adm0_a3_un 0 ABW 533 533 AW ABW NA ABW ABW NA 1 AFG 004 004 AF AFG NA AFG AFG NA 2 AGO 024 024 AO AGO NA AGO AGO NA 3 AIA 660 660 <NA> <NA> NA AIA AIA NA 4 ALB 008 008 AL ALB NA ALB ALB NA 5 ALA 248 248 <NA> <NA> NA ALA ALD NA 6 AND 020 020 AD ADO NA AND AND NA 7 ARE 784 784 AE ARE NA ARE ARE NA 8 ARG 032 032 AR ARG NA ARG ARG NA 9 ARM 051 051 AM ARM NA ARM ARM NA adm0_a3_wb continent region_un subregion region_wb 0 NA North America Americas Caribbean Latin America & Caribbean 1 NA Asia Asia Southern Asia South Asia 2 NA Africa Africa Middle Africa Sub-Saharan Africa 3 NA North America Americas Caribbean Latin America & Caribbean 4 NA Europe Europe Southern Europe Europe & Central Asia 5 NA Europe Europe Northern Europe Europe & Central Asia 6 NA Europe Europe Southern Europe Europe & Central Asia 7 NA Asia Asia Western Asia Middle East & North Africa 8 NA South America Americas South America Latin America & Caribbean 9 NA Asia Asia Western Asia Europe & Central Asia name_len long_len abbrev_len tiny homepart geometry 0 5 5 5 4 NA MULTIPOLYGON (((-69.89912 1... 1 11 11 4 NA 1 MULTIPOLYGON (((74.89131 37... 2 6 6 4 NA 1 MULTIPOLYGON (((14.19082 -5... 3 8 8 4 NA NA MULTIPOLYGON (((-63.00122 1... 4 7 7 4 NA 1 MULTIPOLYGON (((20.06396 42... 5 5 13 5 5 NA MULTIPOLYGON (((20.61133 60... 6 7 7 4 5 1 MULTIPOLYGON (((1.706055 42... 7 20 20 6 NA 1 MULTIPOLYGON (((53.92783 24... 8 9 9 4 NA 1 MULTIPOLYGON (((-64.54917 -... 9 7 7 4 NA 1 MULTIPOLYGON (((45.55234 40... ``` ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% * select(name, continent, geometry) ``` ] .right-panel-wether-auto[ ``` Simple feature collection with 241 features and 2 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 First 10 features: name continent geometry 0 Aruba North America MULTIPOLYGON (((-69.89912 1... 1 Afghanistan Asia MULTIPOLYGON (((74.89131 37... 2 Angola Africa MULTIPOLYGON (((14.19082 -5... 3 Anguilla North America MULTIPOLYGON (((-63.00122 1... 4 Albania Europe MULTIPOLYGON (((20.06396 42... 5 Aland Europe MULTIPOLYGON (((20.61133 60... 6 Andorra Europe MULTIPOLYGON (((1.706055 42... 7 United Arab Emirates Asia MULTIPOLYGON (((53.92783 24... 8 Argentina South America MULTIPOLYGON (((-64.54917 -... 9 Armenia Asia MULTIPOLYGON (((45.55234 40... ``` ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% * filter(name == 'United Kingdom') ``` ] .right-panel-wether-auto[ ``` Simple feature collection with 1 feature and 2 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -8.144824 ymin: 50.02139 xmax: 1.746582 ymax: 60.83188 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 name continent geometry 1 United Kingdom Europe MULTIPOLYGON (((-1.065576 5... ``` ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> *uk ``` ] .right-panel-wether-auto[ ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk *wetherspoon ``` ] .right-panel-wether-auto[ ``` # A tibble: 213 x 5 name location latitude longitude empire_state_burg… <chr> <chr> <dbl> <dbl> <dbl> 1 The Moon Under Wat… Leicester Square, … 51.5 -0.129 11.2 2 The Lord Moon of t… Whitehall, London 51.5 -0.127 11.0 3 Pendrel's Oak Holborn, London 51.5 -0.115 11.0 4 The Cross Keyes City of London, Lo… 51.5 -0.0847 11.0 5 The Mardi Gras Manchester 53.5 -2.35 13.6 6 The King and Castle Windsor 51.5 -0.609 10.6 7 The Hope & Champion Beaconsfield Servi… 51.6 -0.627 9.75 8 Goodman's Field Tower Hamlets, Lon… 51.5 -0.0728 11.0 9 Castle In the Air Manchester 53.5 -2.36 11.5 10 The Ice Wharf Camden, London 51.5 -0.145 11.2 # … with 203 more rows ``` ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% * ggplot() ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_6_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + * ggplot2::geom_sf(data = uk, * fill = "linen") ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_7_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + * geom_point( * aes(x = longitude, * y = latitude, * size = empire_state_burger, * fill = empire_state_burger), * alpha = .6, * color = "black", * stroke = 1, # larger outline width * shape = 21 # point with outline and fill * ) ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_8_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + * scale_size(range = c(.5,15), guide = F) ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_9_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + scale_size(range = c(.5,15), guide = F) + * scale_fill_viridis_c(begin = .2, end = 1) ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_10_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + scale_size(range = c(.5,15), guide = F) + scale_fill_viridis_c(begin = .2, end = 1) + * labs(fill = "Empire State Burger\nCost (pounds)") ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_11_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + scale_size(range = c(.5,15), guide = F) + scale_fill_viridis_c(begin = .2, end = 1) + labs(fill = "Empire State Burger\nCost (pounds)") + * theme_bw() ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_12_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + scale_size(range = c(.5,15), guide = F) + scale_fill_viridis_c(begin = .2, end = 1) + labs(fill = "Empire State Burger\nCost (pounds)") + theme_bw() + * theme(plot.title = element_text(hjust = 0.5)) ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_13_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + scale_size(range = c(.5,15), guide = F) + scale_fill_viridis_c(begin = .2, end = 1) + labs(fill = "Empire State Burger\nCost (pounds)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + * theme(axis.title = element_blank()) ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_14_output-1.png" width="864" /> ] --- count: false .left-panel-wether-auto[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, continent, geometry) %>% filter(name == 'United Kingdom') -> uk wetherspoon %>% ggplot() + ggplot2::geom_sf(data = uk, fill = "linen") + geom_point( aes(x = longitude, y = latitude, size = empire_state_burger, fill = empire_state_burger), alpha = .6, color = "black", stroke = 1, # larger outline width shape = 21 # point with outline and fill ) + scale_size(range = c(.5,15), guide = F) + scale_fill_viridis_c(begin = .2, end = 1) + labs(fill = "Empire State Burger\nCost (pounds)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(axis.title = element_blank()) + * theme(panel.background = * element_rect(fill = "ghostwhite")) ``` ] .right-panel-wether-auto[ <img src="geom_sf_files/figure-html/wether_auto_15_output-1.png" width="864" /> ] <style> .left-panel-wether-auto { color: #777; width: 49%; height: 92%; float: left; font-size: 80% } .right-panel-wether-auto { width: 50%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-wether-auto { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> <img src="geom_sf_files/figure-html/wether-1.png" width="864" /> --- #Example #2 -- The second example will also draw its shapefiles from the rnaturalearth package. We will also use a dataset containing the defense expenditure of NATO member states. We will make a colored map that allows for easy visual comparison of spending levels. This type is called a choropleth map. --- ```r library(readxl) nato_expenditure <- read_excel("nato_expenditure.xlsx") nato_expenditure ``` ``` # A tibble: 29 x 2 name spendingPercap <chr> <dbl> 1 Albania 1.26 2 Belgium 0.93 3 Bulgaria 1.61 4 Canada 1.27 5 Croatia 1.75 6 Czech Republic 1.19 7 Denmark 1.35 8 Estonia 2.13 9 France 1.84 10 Germany 1.36 # … with 19 more rows ``` --- count: false .left-panel-nato-auto[ ```r *nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", * "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") ``` ] .right-panel-nato-auto[ ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") *library(gapminder) ``` ] .right-panel-nato-auto[ ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) *gapminder ``` ] .right-panel-nato-auto[ ``` # A tibble: 1,704 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 1952 28.8 8425333 779. 2 Afghanistan Asia 1957 30.3 9240934 821. 3 Afghanistan Asia 1962 32.0 10267083 853. 4 Afghanistan Asia 1967 34.0 11537966 836. 5 Afghanistan Asia 1972 36.1 13079460 740. 6 Afghanistan Asia 1977 38.4 14880372 786. 7 Afghanistan Asia 1982 39.9 12881816 978. 8 Afghanistan Asia 1987 40.8 13867957 852. 9 Afghanistan Asia 1992 41.7 16317921 649. 10 Afghanistan Asia 1997 41.8 22227415 635. # … with 1,694 more rows ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% * filter(year == 2002) ``` ] .right-panel-nato-auto[ ``` # A tibble: 142 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 2002 42.1 25268405 727. 2 Albania Europe 2002 75.7 3508512 4604. 3 Algeria Africa 2002 71.0 31287142 5288. 4 Angola Africa 2002 41.0 10866106 2773. 5 Argentina Americas 2002 74.3 38331121 8798. 6 Australia Oceania 2002 80.4 19546792 30688. 7 Austria Europe 2002 79.0 8148312 32418. 8 Bahrain Asia 2002 74.8 656397 23404. 9 Bangladesh Asia 2002 62.0 135656790 1136. 10 Belgium Europe 2002 78.3 10311970 30486. # … with 132 more rows ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% * rename(name = country) ``` ] .right-panel-nato-auto[ ``` # A tibble: 142 x 6 name continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 2002 42.1 25268405 727. 2 Albania Europe 2002 75.7 3508512 4604. 3 Algeria Africa 2002 71.0 31287142 5288. 4 Angola Africa 2002 41.0 10866106 2773. 5 Argentina Americas 2002 74.3 38331121 8798. 6 Australia Oceania 2002 80.4 19546792 30688. 7 Austria Europe 2002 79.0 8148312 32418. 8 Bahrain Asia 2002 74.8 656397 23404. 9 Bangladesh Asia 2002 62.0 135656790 1136. 10 Belgium Europe 2002 78.3 10311970 30486. # … with 132 more rows ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> *gapminder_2002_prepped ``` ] .right-panel-nato-auto[ ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped *rnaturalearth::ne_countries( * scale = "medium", returnclass = "sf") ``` ] .right-panel-nato-auto[ ``` Simple feature collection with 241 features and 63 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 First 10 features: scalerank featurecla labelrank sovereignt sov_a3 adm0_dif 0 3 Admin-0 country 5 Netherlands NL1 1 1 1 Admin-0 country 3 Afghanistan AFG 0 2 1 Admin-0 country 3 Angola AGO 0 3 1 Admin-0 country 6 United Kingdom GB1 1 4 1 Admin-0 country 6 Albania ALB 0 5 3 Admin-0 country 6 Finland FI1 1 6 3 Admin-0 country 6 Andorra AND 0 7 1 Admin-0 country 4 United Arab Emirates ARE 0 8 1 Admin-0 country 2 Argentina ARG 0 9 1 Admin-0 country 6 Armenia ARM 0 level type admin adm0_a3 geou_dif 0 2 Country Aruba ABW 0 1 2 Sovereign country Afghanistan AFG 0 2 2 Sovereign country Angola AGO 0 3 2 Dependency Anguilla AIA 0 4 2 Sovereign country Albania ALB 0 5 2 Country Aland ALD 0 6 2 Sovereign country Andorra AND 0 7 2 Sovereign country United Arab Emirates ARE 0 8 2 Sovereign country Argentina ARG 0 9 2 Sovereign country Armenia ARM 0 geounit gu_a3 su_dif subunit su_a3 brk_diff 0 Aruba ABW 0 Aruba ABW 0 1 Afghanistan AFG 0 Afghanistan AFG 0 2 Angola AGO 0 Angola AGO 0 3 Anguilla AIA 0 Anguilla AIA 0 4 Albania ALB 0 Albania ALB 0 5 Aland ALD 0 Aland ALD 0 6 Andorra AND 0 Andorra AND 0 7 United Arab Emirates ARE 0 United Arab Emirates ARE 0 8 Argentina ARG 0 Argentina ARG 0 9 Armenia ARM 0 Armenia ARM 0 name name_long brk_a3 brk_name 0 Aruba Aruba ABW Aruba 1 Afghanistan Afghanistan AFG Afghanistan 2 Angola Angola AGO Angola 3 Anguilla Anguilla AIA Anguilla 4 Albania Albania ALB Albania 5 Aland Aland Islands ALD Aland 6 Andorra Andorra AND Andorra 7 United Arab Emirates United Arab Emirates ARE United Arab Emirates 8 Argentina Argentina ARG Argentina 9 Armenia Armenia ARM Armenia brk_group abbrev postal formal_en formal_fr note_adm0 0 <NA> Aruba AW Aruba <NA> Neth. 1 <NA> Afg. AF Islamic State of Afghanistan <NA> <NA> 2 <NA> Ang. AO People's Republic of Angola <NA> <NA> 3 <NA> Ang. AI <NA> <NA> U.K. 4 <NA> Alb. AL Republic of Albania <NA> <NA> 5 <NA> Aland AI Åland Islands <NA> Fin. 6 <NA> And. AND Principality of Andorra <NA> <NA> 7 <NA> U.A.E. AE United Arab Emirates <NA> <NA> 8 <NA> Arg. AR Argentine Republic <NA> <NA> 9 <NA> Arm. ARM Republic of Armenia <NA> <NA> note_brk name_sort name_alt mapcolor7 mapcolor8 mapcolor9 0 <NA> Aruba <NA> 4 2 2 1 <NA> Afghanistan <NA> 5 6 8 2 <NA> Angola <NA> 3 2 6 3 <NA> Anguilla <NA> 6 6 6 4 <NA> Albania <NA> 1 4 1 5 <NA> Aland <NA> 4 1 4 6 <NA> Andorra <NA> 1 4 1 7 <NA> United Arab Emirates <NA> 2 1 3 8 <NA> Argentina <NA> 3 1 3 9 <NA> Armenia <NA> 3 1 2 mapcolor13 pop_est gdp_md_est pop_year lastcensus gdp_year 0 9 103065 2258.0 NA 2010 NA 1 7 28400000 22270.0 NA 1979 NA 2 1 12799293 110300.0 NA 1970 NA 3 3 14436 108.9 NA NA NA 4 6 3639453 21810.0 NA 2001 NA 5 6 27153 1563.0 NA NA NA 6 8 83888 3660.0 NA 1989 NA 7 3 4798491 184300.0 NA 2010 NA 8 13 40913584 573900.0 NA 2010 NA 9 10 2967004 18770.0 NA 2001 NA economy income_grp wikipedia fips_10 iso_a2 0 6. Developing region 2. High income: nonOECD NA <NA> AW 1 7. Least developed region 5. Low income NA <NA> AF 2 7. Least developed region 3. Upper middle income NA <NA> AO 3 6. Developing region 3. Upper middle income NA <NA> AI 4 6. Developing region 4. Lower middle income NA <NA> AL 5 2. Developed region: nonG7 1. High income: OECD NA <NA> AX 6 2. Developed region: nonG7 2. High income: nonOECD NA <NA> AD 7 6. Developing region 2. High income: nonOECD NA <NA> AE 8 5. Emerging region: G20 3. Upper middle income NA <NA> AR 9 6. Developing region 4. Lower middle income NA <NA> AM iso_a3 iso_n3 un_a3 wb_a2 wb_a3 woe_id adm0_a3_is adm0_a3_us adm0_a3_un 0 ABW 533 533 AW ABW NA ABW ABW NA 1 AFG 004 004 AF AFG NA AFG AFG NA 2 AGO 024 024 AO AGO NA AGO AGO NA 3 AIA 660 660 <NA> <NA> NA AIA AIA NA 4 ALB 008 008 AL ALB NA ALB ALB NA 5 ALA 248 248 <NA> <NA> NA ALA ALD NA 6 AND 020 020 AD ADO NA AND AND NA 7 ARE 784 784 AE ARE NA ARE ARE NA 8 ARG 032 032 AR ARG NA ARG ARG NA 9 ARM 051 051 AM ARM NA ARM ARM NA adm0_a3_wb continent region_un subregion region_wb 0 NA North America Americas Caribbean Latin America & Caribbean 1 NA Asia Asia Southern Asia South Asia 2 NA Africa Africa Middle Africa Sub-Saharan Africa 3 NA North America Americas Caribbean Latin America & Caribbean 4 NA Europe Europe Southern Europe Europe & Central Asia 5 NA Europe Europe Northern Europe Europe & Central Asia 6 NA Europe Europe Southern Europe Europe & Central Asia 7 NA Asia Asia Western Asia Middle East & North Africa 8 NA South America Americas South America Latin America & Caribbean 9 NA Asia Asia Western Asia Europe & Central Asia name_len long_len abbrev_len tiny homepart geometry 0 5 5 5 4 NA MULTIPOLYGON (((-69.89912 1... 1 11 11 4 NA 1 MULTIPOLYGON (((74.89131 37... 2 6 6 4 NA 1 MULTIPOLYGON (((14.19082 -5... 3 8 8 4 NA NA MULTIPOLYGON (((-63.00122 1... 4 7 7 4 NA 1 MULTIPOLYGON (((20.06396 42... 5 5 13 5 5 NA MULTIPOLYGON (((20.61133 60... 6 7 7 4 5 1 MULTIPOLYGON (((1.706055 42... 7 20 20 6 NA 1 MULTIPOLYGON (((53.92783 24... 8 9 9 4 NA 1 MULTIPOLYGON (((-64.54917 -... 9 7 7 4 NA 1 MULTIPOLYGON (((45.55234 40... ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% * select(name, pop_est, gdp_md_est, * continent, geometry) ``` ] .right-panel-nato-auto[ ``` Simple feature collection with 241 features and 4 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 First 10 features: name pop_est gdp_md_est continent 0 Aruba 103065 2258.0 North America 1 Afghanistan 28400000 22270.0 Asia 2 Angola 12799293 110300.0 Africa 3 Anguilla 14436 108.9 North America 4 Albania 3639453 21810.0 Europe 5 Aland 27153 1563.0 Europe 6 Andorra 83888 3660.0 Europe 7 United Arab Emirates 4798491 184300.0 Asia 8 Argentina 40913584 573900.0 South America 9 Armenia 2967004 18770.0 Asia geometry 0 MULTIPOLYGON (((-69.89912 1... 1 MULTIPOLYGON (((74.89131 37... 2 MULTIPOLYGON (((14.19082 -5... 3 MULTIPOLYGON (((-63.00122 1... 4 MULTIPOLYGON (((20.06396 42... 5 MULTIPOLYGON (((20.61133 60... 6 MULTIPOLYGON (((1.706055 42... 7 MULTIPOLYGON (((53.92783 24... 8 MULTIPOLYGON (((-64.54917 -... 9 MULTIPOLYGON (((45.55234 40... ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% * filter(name %in% nato_names) ``` ] .right-panel-nato-auto[ ``` Simple feature collection with 28 features and 4 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -178.1945 ymin: -21.36904 xmax: 179.78 ymax: 83.11611 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 First 10 features: name pop_est gdp_md_est continent 1 Albania 3639453 21810 Europe 2 Belgium 10414336 389300 Europe 3 Bulgaria 7204687 93750 Europe 4 Canada 33487208 1300000 North America 5 Germany 82329758 2918000 Europe 6 Denmark 5500510 203600 Europe 7 Spain 40525002 1403000 Europe 8 Estonia 1299371 27410 Europe 9 France 64057792 2128000 Europe 10 United Kingdom 62262000 1977704 Europe geometry 1 MULTIPOLYGON (((20.06396 42... 2 MULTIPOLYGON (((4.816016 51... 3 MULTIPOLYGON (((28.58535 43... 4 MULTIPOLYGON (((-59.7876 43... 5 MULTIPOLYGON (((14.19824 53... 6 MULTIPOLYGON (((11.36143 54... 7 MULTIPOLYGON (((-17.88794 2... 8 MULTIPOLYGON (((22.61738 58... 9 MULTIPOLYGON (((55.79736 -2... 10 MULTIPOLYGON (((-1.065576 5... ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% * left_join(gapminder_2002_prepped, by = "name") ``` ] .right-panel-nato-auto[ ``` Simple feature collection with 28 features and 9 fields geometry type: MULTIPOLYGON dimension: XY bbox: xmin: -178.1945 ymin: -21.36904 xmax: 179.78 ymax: 83.11611 CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 First 10 features: name pop_est gdp_md_est continent.x continent.y year lifeExp 1 Albania 3639453 21810 Europe Europe 2002 75.651 2 Belgium 10414336 389300 Europe Europe 2002 78.320 3 Bulgaria 7204687 93750 Europe Europe 2002 72.140 4 Canada 33487208 1300000 North America Americas 2002 79.770 5 Germany 82329758 2918000 Europe Europe 2002 78.670 6 Denmark 5500510 203600 Europe Europe 2002 77.180 7 Spain 40525002 1403000 Europe Europe 2002 79.780 8 Estonia 1299371 27410 Europe <NA> NA NA 9 France 64057792 2128000 Europe Europe 2002 79.590 10 United Kingdom 62262000 1977704 Europe Europe 2002 78.471 pop gdpPercap geometry 1 3508512 4604.212 MULTIPOLYGON (((20.06396 42... 2 10311970 30485.884 MULTIPOLYGON (((4.816016 51... 3 7661799 7696.778 MULTIPOLYGON (((28.58535 43... 4 31902268 33328.965 MULTIPOLYGON (((-59.7876 43... 5 82350671 30035.802 MULTIPOLYGON (((14.19824 53... 6 5374693 32166.500 MULTIPOLYGON (((11.36143 54... 7 40152517 24835.472 MULTIPOLYGON (((-17.88794 2... 8 NA NA MULTIPOLYGON (((22.61738 58... 9 59925035 28926.032 MULTIPOLYGON (((55.79736 -2... 10 59912431 29478.999 MULTIPOLYGON (((-1.065576 5... ``` ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> * nato_countries ``` ] .right-panel-nato-auto[ ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries *ggplot(data = nato_countries) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_12_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + * ggplot2::geom_sf(data = nato_countries) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_13_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + * aes(fill = lifeExp) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_14_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + aes(fill = lifeExp) + * scale_fill_viridis_c(option = "magma", direction = -1) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_15_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + aes(fill = lifeExp) + scale_fill_viridis_c(option = "magma", direction = -1) + * ggplot2::coord_sf(xlim = c(-175, 47.5), * ylim = c(23, 85), * expand = FALSE) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_16_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + aes(fill = lifeExp) + scale_fill_viridis_c(option = "magma", direction = -1) + ggplot2::coord_sf(xlim = c(-175, 47.5), ylim = c(23, 85), expand = FALSE) + * labs(title = "Life Expectancy, 2002", * subtitle = "NATO Member States", * fill = "Share of GDP (%)") ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_17_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + aes(fill = lifeExp) + scale_fill_viridis_c(option = "magma", direction = -1) + ggplot2::coord_sf(xlim = c(-175, 47.5), ylim = c(23, 85), expand = FALSE) + labs(title = "Life Expectancy, 2002", subtitle = "NATO Member States", fill = "Share of GDP (%)") + * theme_bw() ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_18_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + aes(fill = lifeExp) + scale_fill_viridis_c(option = "magma", direction = -1) + ggplot2::coord_sf(xlim = c(-175, 47.5), ylim = c(23, 85), expand = FALSE) + labs(title = "Life Expectancy, 2002", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + * theme(plot.title = * element_text(hjust = 0.5)) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_19_output-1.png" width="864" /> ] --- count: false .left-panel-nato-auto[ ```r nato_names <- c("Albania", "Belgium", "Bulgaria", "Canada", "Croatia", "Czech Republic", "Denmark", "Estonia", "France", "Germany", "Greece", "Hungary", "Iceland", "Italy", "Latvia", "Lithuania", "Luxembourg", "Montenegro", "Netherlands", "Norway", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", "Spain", "Turkey", "United Kingdom", "United States") library(gapminder) gapminder %>% filter(year == 2002) %>% rename(name = country) -> gapminder_2002_prepped rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") %>% select(name, pop_est, gdp_md_est, continent, geometry) %>% filter(name %in% nato_names) %>% left_join(gapminder_2002_prepped, by = "name") -> nato_countries ggplot(data = nato_countries) + ggplot2::geom_sf(data = nato_countries) + aes(fill = lifeExp) + scale_fill_viridis_c(option = "magma", direction = -1) + ggplot2::coord_sf(xlim = c(-175, 47.5), ylim = c(23, 85), expand = FALSE) + labs(title = "Life Expectancy, 2002", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + * theme(plot.subtitle = * element_text(hjust = 0.5)) ``` ] .right-panel-nato-auto[ <img src="geom_sf_files/figure-html/nato_auto_20_output-1.png" width="864" /> ] <style> .left-panel-nato-auto { color: #777; width: 38.6138613861386%; height: 92%; float: left; font-size: 80% } .right-panel-nato-auto { width: 59.4059405940594%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-nato-auto { width: 0%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + coord_sf() ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_1_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_2_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=merc") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_3_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=155 +lat_0=-90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_4_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=145 +lat_0=-90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_5_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=135 +lat_0=-90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_6_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=115 +lat_0=-50 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_7_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=115 +lat_0=-30 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_8_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=115 +lat_0=90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_9_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=0 +lon_0=90 +lat_0=90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_10_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=10 +lon_0=70 +lat_0=90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_11_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=40 +lon_0=15 +lat_0=90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_12_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=laea +y_0=50 +lon_0=0 +lat_0=90 +ellps=WGS84 +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_13_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=igh") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_14_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_15_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=77.5 +lon_0=-56 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_16_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=77.5 +lon_0=-36 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_17_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=77.5 +lon_0=-16 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_18_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=77.5 +lon_0=0 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_19_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=77.5 +lon_0=15 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_20_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=89.5 +lat_2=45.5 +lat_0=77.5 +lon_0=90 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_21_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=110 +lat_2=45.5 +lat_0=77.5 +lon_0=90 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_22_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=aea +lat_1=120 +lat_2=45.5 +lat_0=77.5 +lon_0=90 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_23_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=stere +lat_0=-90") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_24_output-1.png" width="864" /> ] --- count: false .left-panel-projections-rotate[ ```r rnaturalearth::ne_countries( scale = "medium", returnclass = "sf") -> ne_countries ggplot(data = ne_countries) + ggplot2::geom_sf(data = ne_countries) + aes(fill = pop_est) + scale_fill_viridis_c(option = "magma") + labs(title = "Defense Expenditure by Share of GDP (%)", subtitle = "NATO Member States", fill = "Share of GDP (%)") + theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) + * coord_sf(crs = "+proj=moll") ``` ] .right-panel-projections-rotate[ <img src="geom_sf_files/figure-html/projections_rotate_25_output-1.png" width="864" /> ] <style> .left-panel-projections-rotate { color: #777; width: 59%; height: 92%; float: left; font-size: 80% } .right-panel-projections-rotate { width: 40%; float: right; padding-left: 1%; font-size: 80% } .middle-panel-projections-rotate { width: NA%; float: left; padding-left: 1%; font-size: 80% } </style> --- <style type="text/css"> .remark-code{line-height: 1.5; font-size: 60%} </style>