ECON 413
Maps
Erol
Taymaz
Department of Economics
Middle East Technical
University
Shape files
Raster files
An excellent source of map data: http://www.naturalearthdata.com/
## [1] "sf" "data.frame"
## Classes 'sf' and 'data.frame': 241 obs. of 64 variables:
## $ scalerank : int 3 1 1 1 1 3 3 1 1 1 ...
## $ featurecla: chr "Admin-0 country" "Admin-0 country" "Admin-0 country" "Admin-0 country" ...
## $ labelrank : num 5 3 3 6 6 6 6 4 2 6 ...
## $ sovereignt: chr "Netherlands" "Afghanistan" "Angola" "United Kingdom" ...
## $ sov_a3 : chr "NL1" "AFG" "AGO" "GB1" ...
## $ adm0_dif : num 1 0 0 1 0 1 0 0 0 0 ...
## $ level : num 2 2 2 2 2 2 2 2 2 2 ...
## $ type : chr "Country" "Sovereign country" "Sovereign country" "Dependency" ...
## $ admin : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ adm0_a3 : chr "ABW" "AFG" "AGO" "AIA" ...
## $ geou_dif : num 0 0 0 0 0 0 0 0 0 0 ...
## $ geounit : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ gu_a3 : chr "ABW" "AFG" "AGO" "AIA" ...
## $ su_dif : num 0 0 0 0 0 0 0 0 0 0 ...
## $ subunit : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ su_a3 : chr "ABW" "AFG" "AGO" "AIA" ...
## $ brk_diff : num 0 0 0 0 0 0 0 0 0 0 ...
## $ name : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ name_long : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ brk_a3 : chr "ABW" "AFG" "AGO" "AIA" ...
## $ brk_name : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ brk_group : chr NA NA NA NA ...
## $ abbrev : chr "Aruba" "Afg." "Ang." "Ang." ...
## $ postal : chr "AW" "AF" "AO" "AI" ...
## $ formal_en : chr "Aruba" "Islamic State of Afghanistan" "People's Republic of Angola" NA ...
## $ formal_fr : chr NA NA NA NA ...
## $ note_adm0 : chr "Neth." NA NA "U.K." ...
## $ note_brk : chr NA NA NA NA ...
## $ name_sort : chr "Aruba" "Afghanistan" "Angola" "Anguilla" ...
## $ name_alt : chr NA NA NA NA ...
## $ mapcolor7 : num 4 5 3 6 1 4 1 2 3 3 ...
## $ mapcolor8 : num 2 6 2 6 4 1 4 1 1 1 ...
## $ mapcolor9 : num 2 8 6 6 1 4 1 3 3 2 ...
## $ mapcolor13: num 9 7 1 3 6 6 8 3 13 10 ...
## $ pop_est : num 103065 28400000 12799293 14436 3639453 ...
## $ gdp_md_est: num 2258 22270 110300 109 21810 ...
## $ pop_year : num NA NA NA NA NA NA NA NA NA NA ...
## $ lastcensus: num 2010 1979 1970 NA 2001 ...
## $ gdp_year : num NA NA NA NA NA NA NA NA NA NA ...
## $ economy : chr "6. Developing region" "7. Least developed region" "7. Least developed region" "6. Developing region" ...
## $ income_grp: chr "2. High income: nonOECD" "5. Low income" "3. Upper middle income" "3. Upper middle income" ...
## $ wikipedia : num NA NA NA NA NA NA NA NA NA NA ...
## $ fips_10 : chr NA NA NA NA ...
## $ iso_a2 : chr "AW" "AF" "AO" "AI" ...
## $ iso_a3 : chr "ABW" "AFG" "AGO" "AIA" ...
## $ iso_n3 : chr "533" "004" "024" "660" ...
## $ un_a3 : chr "533" "004" "024" "660" ...
## $ wb_a2 : chr "AW" "AF" "AO" NA ...
## $ wb_a3 : chr "ABW" "AFG" "AGO" NA ...
## $ woe_id : num NA NA NA NA NA NA NA NA NA NA ...
## $ adm0_a3_is: chr "ABW" "AFG" "AGO" "AIA" ...
## $ adm0_a3_us: chr "ABW" "AFG" "AGO" "AIA" ...
## $ adm0_a3_un: num NA NA NA NA NA NA NA NA NA NA ...
## $ adm0_a3_wb: num NA NA NA NA NA NA NA NA NA NA ...
## $ continent : chr "North America" "Asia" "Africa" "North America" ...
## $ region_un : chr "Americas" "Asia" "Africa" "Americas" ...
## $ subregion : chr "Caribbean" "Southern Asia" "Middle Africa" "Caribbean" ...
## $ region_wb : chr "Latin America & Caribbean" "South Asia" "Sub-Saharan Africa" "Latin America & Caribbean" ...
## $ name_len : num 5 11 6 8 7 5 7 20 9 7 ...
## $ long_len : num 5 11 6 8 7 13 7 20 9 7 ...
## $ abbrev_len: num 5 4 4 4 4 5 4 6 4 4 ...
## $ tiny : num 4 NA NA NA NA 5 5 NA NA NA ...
## $ homepart : num NA 1 1 NA 1 NA 1 1 1 1 ...
## $ geometry :sfc_MULTIPOLYGON of length 241; first list element: List of 1
## ..$ :List of 1
## .. ..$ : num [1:10, 1:2] -69.9 -69.9 -69.9 -70 -70.1 ...
## ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
## - attr(*, "sf_column")= chr "geometry"
## - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
## ..- attr(*, "names")= chr [1:63] "scalerank" "featurecla" "labelrank" "sovereignt" ...
## Simple feature collection with 6 features and 63 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -70.06611 ymin: -18.01973 xmax: 74.89131 ymax: 60.40581
## Geodetic CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## scalerank featurecla labelrank sovereignt sov_a3 adm0_dif level
## 0 3 Admin-0 country 5 Netherlands NL1 1 2
## 1 1 Admin-0 country 3 Afghanistan AFG 0 2
## 2 1 Admin-0 country 3 Angola AGO 0 2
## 3 1 Admin-0 country 6 United Kingdom GB1 1 2
## 4 1 Admin-0 country 6 Albania ALB 0 2
## 5 3 Admin-0 country 6 Finland FI1 1 2
## type admin adm0_a3 geou_dif geounit gu_a3 su_dif
## 0 Country Aruba ABW 0 Aruba ABW 0
## 1 Sovereign country Afghanistan AFG 0 Afghanistan AFG 0
## 2 Sovereign country Angola AGO 0 Angola AGO 0
## 3 Dependency Anguilla AIA 0 Anguilla AIA 0
## 4 Sovereign country Albania ALB 0 Albania ALB 0
## 5 Country Aland ALD 0 Aland ALD 0
## subunit su_a3 brk_diff name name_long brk_a3 brk_name
## 0 Aruba ABW 0 Aruba Aruba ABW Aruba
## 1 Afghanistan AFG 0 Afghanistan Afghanistan AFG Afghanistan
## 2 Angola AGO 0 Angola Angola AGO Angola
## 3 Anguilla AIA 0 Anguilla Anguilla AIA Anguilla
## 4 Albania ALB 0 Albania Albania ALB Albania
## 5 Aland ALD 0 Aland Aland Islands ALD Aland
## 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.
## note_brk name_sort name_alt mapcolor7 mapcolor8 mapcolor9 mapcolor13
## 0 <NA> Aruba <NA> 4 2 2 9
## 1 <NA> Afghanistan <NA> 5 6 8 7
## 2 <NA> Angola <NA> 3 2 6 1
## 3 <NA> Anguilla <NA> 6 6 6 3
## 4 <NA> Albania <NA> 1 4 1 6
## 5 <NA> Aland <NA> 4 1 4 6
## pop_est gdp_md_est pop_year lastcensus gdp_year economy
## 0 103065 2258.0 NA 2010 NA 6. Developing region
## 1 28400000 22270.0 NA 1979 NA 7. Least developed region
## 2 12799293 110300.0 NA 1970 NA 7. Least developed region
## 3 14436 108.9 NA NA NA 6. Developing region
## 4 3639453 21810.0 NA 2001 NA 6. Developing region
## 5 27153 1563.0 NA NA NA 2. Developed region: nonG7
## income_grp wikipedia fips_10 iso_a2 iso_a3 iso_n3 un_a3 wb_a2
## 0 2. High income: nonOECD NA <NA> AW ABW 533 533 AW
## 1 5. Low income NA <NA> AF AFG 004 004 AF
## 2 3. Upper middle income NA <NA> AO AGO 024 024 AO
## 3 3. Upper middle income NA <NA> AI AIA 660 660 <NA>
## 4 4. Lower middle income NA <NA> AL ALB 008 008 AL
## 5 1. High income: OECD NA <NA> AX ALA 248 248 <NA>
## wb_a3 woe_id adm0_a3_is adm0_a3_us adm0_a3_un adm0_a3_wb continent
## 0 ABW NA ABW ABW NA NA North America
## 1 AFG NA AFG AFG NA NA Asia
## 2 AGO NA AGO AGO NA NA Africa
## 3 <NA> NA AIA AIA NA NA North America
## 4 ALB NA ALB ALB NA NA Europe
## 5 <NA> NA ALA ALD NA NA Europe
## region_un subregion region_wb name_len long_len
## 0 Americas Caribbean Latin America & Caribbean 5 5
## 1 Asia Southern Asia South Asia 11 11
## 2 Africa Middle Africa Sub-Saharan Africa 6 6
## 3 Americas Caribbean Latin America & Caribbean 8 8
## 4 Europe Southern Europe Europe & Central Asia 7 7
## 5 Europe Northern Europe Europe & Central Asia 5 13
## abbrev_len tiny homepart geometry
## 0 5 4 NA MULTIPOLYGON (((-69.89912 1...
## 1 4 NA 1 MULTIPOLYGON (((74.89131 37...
## 2 4 NA 1 MULTIPOLYGON (((14.19082 -5...
## 3 4 NA NA MULTIPOLYGON (((-63.00122 1...
## 4 4 NA 1 MULTIPOLYGON (((20.06396 42...
## 5 5 5 NA MULTIPOLYGON (((20.61133 60...
## Simple feature collection with 1 feature and 63 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 25.66895 ymin: 35.83145 xmax: 44.81719 ymax: 42.09326
## Geodetic CRS: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## scalerank featurecla labelrank sovereignt sov_a3 adm0_dif level
## 220 1 Admin-0 country 2 Turkey TUR 0 2
## type admin adm0_a3 geou_dif geounit gu_a3 su_dif subunit
## 220 Sovereign country Turkey TUR 0 Turkey TUR 0 Turkey
## su_a3 brk_diff name name_long brk_a3 brk_name brk_group abbrev postal
## 220 TUR 0 Turkey Turkey TUR Turkey <NA> Tur. TR
## formal_en formal_fr note_adm0 note_brk name_sort name_alt
## 220 Republic of Turkey <NA> <NA> <NA> Turkey <NA>
## mapcolor7 mapcolor8 mapcolor9 mapcolor13 pop_est gdp_md_est pop_year
## 220 6 3 8 4 76805524 902700 NA
## lastcensus gdp_year economy income_grp
## 220 2000 NA 4. Emerging region: MIKT 3. Upper middle income
## wikipedia fips_10 iso_a2 iso_a3 iso_n3 un_a3 wb_a2 wb_a3 woe_id adm0_a3_is
## 220 NA <NA> TR TUR 792 792 TR TUR NA TUR
## adm0_a3_us adm0_a3_un adm0_a3_wb continent region_un subregion
## 220 TUR NA NA Asia Asia Western Asia
## region_wb name_len long_len abbrev_len tiny homepart
## 220 Europe & Central Asia 6 6 4 NA 1
## geometry
## 220 MULTIPOLYGON (((25.97002 40...
ggplot(data = world) + geom_sf() + theme_bw() +
labs(title = "World map",
subtitle = paste0(length(unique(world$sov_a3)), " countries"),
x = "Longitude", y = "Latitude")
ctitles <- labs(title = "World map",
subtitle = paste0(length(unique(world$sov_a3)), " countries"),
x = "Longitude", y = "Latitude")
ggplot(data = world) +
geom_sf() +
theme_bw() + ctitles
ggplot(data = world) +
geom_sf(color = "black", fill = "lightblue") +
coord_sf(ylim = c(-65, 90), expand = FALSE) +
theme_bw() + ctitles
ggplot(data = world) +
geom_sf(aes(fill = economy)) +
coord_sf(ylim = c(-65, 90), expand = FALSE) +
theme_bw() + ctitles +
scale_fill_viridis_d(option = "plasma")
ggplot(data = world) +
geom_sf(aes(fill = pop_est)) +
coord_sf(ylim = c(-65, 90), expand = FALSE) +
theme_bw() + ctitles +
scale_fill_viridis_c(option = "plasma", trans = "sqrt")
## [1] "sf" "data.frame"
## Classes 'sf' and 'data.frame': 81 obs. of 122 variables:
## $ featurecla: chr "Admin-1 states provinces lakes" "Admin-1 states provinces lakes" "Admin-1 states provinces lakes" "Admin-1 states provinces lakes" ...
## $ scalerank : int 6 6 6 6 6 6 6 6 6 6 ...
## $ adm1_code : chr "TUR-4839" "TUR-2298" "TUR-3044" "TUR-3047" ...
## $ diss_me : int 4839 2298 3044 3047 4840 2307 3048 2241 2240 3040 ...
## $ iso_3166_2: chr "TR-75" "TR-08" "TR-73" "TR-30" ...
## $ wikipedia : chr "http://en.wikipedia.org/wiki/Ardahan_Province" NA NA NA ...
## $ iso_a2 : chr "TR" "TR" "TR" "TR" ...
## $ adm0_sr : int 1 1 1 1 1 1 1 1 1 1 ...
## $ name : chr "Ardahan" "Artvin" "Sirnak" "Hakkari" ...
## $ name_alt : chr NA "Çoruh" "Şırnak" NA ...
## $ name_local: chr NA NA NA NA ...
## $ type : chr "Il" "Il" "Il" "Il" ...
## $ type_en : chr "Province" "Province" "Province" "Province" ...
## $ code_local: chr NA NA NA NA ...
## $ code_hasc : chr "TR.AR" "TR.AV" "TR.SR" "TR.HK" ...
## $ note : chr NA NA NA NA ...
## $ hasc_maybe: chr NA NA NA NA ...
## $ region : chr NA NA NA NA ...
## $ region_cod: chr NA NA NA NA ...
## $ provnum_ne: int 20021 20019 20029 20027 0 20020 20018 20005 20004 20021 ...
## $ gadm_level: int 1 1 1 1 1 1 1 1 1 1 ...
## $ check_me : int 20 20 20 20 20 20 20 20 20 20 ...
## $ datarank : int 5 5 5 5 5 5 5 5 5 5 ...
## $ abbrev : chr NA NA NA NA ...
## $ postal : chr "AR" "AV" "SR" "HK" ...
## $ area_sqkm : int 0 0 0 0 0 0 0 0 0 0 ...
## $ sameascity: int 7 -99 -99 7 7 7 7 7 7 7 ...
## $ labelrank : int 7 6 6 7 7 7 7 7 7 7 ...
## $ name_len : int 7 6 6 7 5 4 3 10 6 4 ...
## $ mapcolor9 : int 8 8 8 8 8 8 8 8 8 8 ...
## $ mapcolor13: int 4 4 4 4 4 4 4 4 4 4 ...
## $ fips : chr "TU86" "TU08" "TU80" "TU70" ...
## $ fips_alt : chr NA NA NA NA ...
## $ woe_id : int 20070284 2347265 2347330 2347320 20070183 2347261 2347316 2347294 2347279 2347291 ...
## $ woe_label : chr "Ardahan, TR, Turkey" "Artvin, TR, Turkey" "Şırnak, TR, Turkey" "Hakkâri, TR, Turkey" ...
## $ woe_name : chr "Ardahan" "Artvin" "Sirnak" "Hakkari" ...
## $ latitude : num 41.2 41 37.4 37.6 39.8 ...
## $ longitude : num 42.8 41.8 42.5 44.1 44 ...
## $ sov_a3 : chr "TUR" "TUR" "TUR" "TUR" ...
## $ adm0_a3 : chr "TUR" "TUR" "TUR" "TUR" ...
## $ adm0_label: int 2 2 2 2 2 2 2 2 2 2 ...
## $ admin : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
## $ geonunit : chr "Turkey" "Turkey" "Turkey" "Turkey" ...
## $ gu_a3 : chr "TUR" "TUR" "TUR" "TUR" ...
## $ gn_id : int 862470 751816 443189 312888 443184 325163 298113 743165 747711 743942 ...
## $ gn_name : chr "Ardahan" "Artvin" "Sirnak" "Hakkari" ...
## $ gns_id : int 9034903 -735804 9035020 -752257 9034900 -733172 -774910 -760442 -747444 -758248 ...
## $ gns_name : chr "Ardahan Ili" "Artvin Ili" "Sirnak Ili" "Hakkari Ili" ...
## $ gn_level : int 1 1 1 1 1 1 1 1 1 1 ...
## $ gn_region : chr NA NA NA NA ...
## $ gn_a1_code: chr "TR.86" "TR.08" "TR.80" "TR.70" ...
## $ region_sub: chr NA NA NA NA ...
## $ sub_code : chr NA NA NA NA ...
## $ gns_level : int 1 1 1 1 1 1 1 1 1 1 ...
## $ gns_lang : chr "tur" "tur" "tur" "tur" ...
## $ gns_adm1 : chr "TU86" "TU08" "TU80" "TU70" ...
## $ gns_region: chr NA NA NA NA ...
## $ min_label : num 7 7 7 7 7 7 7 7 7 7 ...
## $ max_label : num 11 11 11 11 11 11 11 11 11 11 ...
## $ min_zoom : num 7 7 7 7 7 7 7 7 7 7 ...
## $ wikidataid: chr "Q79840" "Q43745" "Q647378" "Q93209" ...
## $ name_ar : chr "أرداهان" "أرتوين" "شرناق" "هكاري" ...
## $ name_bn : chr "আরদাহান প্রদেশ" "আর্টভিন প্রদেশ" "সিনাক প্রদেশ" "হাক্কারি প্রদেশ" ...
## $ name_de : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_en : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_es : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_fr : chr "Ardahan" "Artvin" "Şırnak" "Hakkari" ...
## $ name_el : chr "Αρνταχάν" "Επαρχία Αρτβίν" "Σίρνακ" "Χακάρι" ...
## $ name_hi : chr "अर्दहन प्रांत" "आर्टविन प्रांत" "सिर्नक प्रांत" "हक्कारी प्रोविंस" ...
## $ name_hu : chr "Ardahan" "Artvin" "Şırnak" "Hakkari" ...
## $ name_id : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_it : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_ja : chr "アルダハン県" "アルトヴィン県" "シュルナク県" "ハッキャリ県" ...
## $ name_ko : chr "아르다한" "아르트빈" "시르나크" "하카리" ...
## $ name_nl : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_pl : chr "Ardahan" "Artvin" "Şırnak" "Hakkari" ...
## $ name_pt : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_ru : chr "Ардахан" "Артвин" "Ширнак" "Хаккяри" ...
## $ name_sv : chr "Ardahan" "Artvin" "Şırnak" "Hakkari" ...
## $ name_tr : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_vi : chr "Ardahan" "Artvin" "Şırnak" "Hakkâri" ...
## $ name_zh : chr "阿尔达汉省" "阿尔特温省" "舍尔纳克省" "哈卡里省" ...
## $ ne_id : num 1.16e+09 1.16e+09 1.16e+09 1.16e+09 1.16e+09 ...
## $ name_he : chr "ארדהאן" "ארטווין" "סירנאק" "האקארי" ...
## $ name_uk : chr "Ардахан" "Артвін" "Ширнак" "Хаккярі" ...
## $ name_ur : chr "ارداہان صوبہ" "آرتوین صوبہ" "شرناق صوبہ" "حکاری صوبہ" ...
## $ name_fa : chr "استان اردهان" "استان آرتوین" "استان شرناق" "استان حکاری" ...
## $ name_zht : chr "阿尔达汉省" "阿尔特温省" "舍爾納克省" "哈卡里省" ...
## $ FCLASS_ISO: chr NA NA NA NA ...
## $ FCLASS_US : chr NA NA NA NA ...
## $ FCLASS_FR : chr NA NA NA NA ...
## $ FCLASS_RU : chr NA NA NA NA ...
## $ FCLASS_ES : chr NA NA NA NA ...
## $ FCLASS_CN : chr NA NA NA NA ...
## $ FCLASS_TW : chr NA NA NA NA ...
## $ FCLASS_IN : chr NA NA NA NA ...
## $ FCLASS_NP : chr NA NA NA NA ...
## $ FCLASS_PK : chr NA NA NA NA ...
## $ FCLASS_DE : chr NA NA NA NA ...
## [list output truncated]
## - attr(*, "sf_column")= chr "geometry"
## - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
## ..- attr(*, "names")= chr [1:121] "featurecla" "scalerank" "adm1_code" "diss_me" ...
library(rvest)
pwiki <- read_html("https://en.wikipedia.org/wiki/Provinces_of_Turkey")
ptables <- html_elements(pwiki, "table")
length(ptables)
## [1] 12
## # A tibble: 6 × 7
## `` Name Capital `Area (km2)` Populationcensus22.1…¹ Populationcensus2.11…²
## <int> <chr> <chr> <chr> <chr> <chr>
## 1 1 Adana Adana 14,045.56 1,849,478 2,102,375
## 2 2 Adıy… Adıyam… 7,606.16 623,811 594,163
## 3 3 Afyo… Afyonk… 14,718.63 812,416 701,461
## 4 4 Ağrı Ağrı 11,498.67 528,744 553,241
## 5 5 Amas… Amasya 5,703.78 365,231 323,331
## 6 6 Anka… Ankara 25,401.94 4,007,860 4,868,418
## # ℹ abbreviated names: ¹Populationcensus22.10.2000, ²Populationcensus2.11.2011
## # ℹ 1 more variable: `Population estimate31.12.2021[1]` <chr>
## tibble [81 × 7] (S3: tbl_df/tbl/data.frame)
## $ id : int [1:81] 1 2 3 4 5 6 7 8 9 10 ...
## $ name_de: chr [1:81] "Adana" "Adıyaman" "Afyonkarahisar" "Ağrı" ...
## $ capital: chr [1:81] "Adana" "Adıyaman" "Afyonkarahisar" "Ağrı" ...
## $ area : chr [1:81] "14,045.56" "7,606.16" "14,718.63" "11,498.67" ...
## $ pop2000: chr [1:81] "1,849,478" "623,811" "812,416" "528,744" ...
## $ pop2011: chr [1:81] "2,102,375" "594,163" "701,461" "553,241" ...
## $ pop2021: chr [1:81] "2,263,373" "632,148" "744,179" "524,069" ...
## # A tibble: 6 × 7
## id name_de capital area pop2000 pop2011 pop2021
## <int> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1 Adana Adana 14,045.56 1,849,478 2,102,375 2,263,373
## 2 2 Adıyaman Adıyaman 7,606.16 623,811 594,163 632,148
## 3 3 Afyonkarahisar Afyonkarahisar 14,718.63 812,416 701,461 744,179
## 4 4 Ağrı Ağrı 11,498.67 528,744 553,241 524,069
## 5 5 Amasya Amasya 5,703.78 365,231 323,331 335,331
## 6 6 Ankara Ankara 25,401.94 4,007,860 4,868,418 5,747,325
# chartr("ğüşıöç", "gusioc", x)
pdat$area <- gsub(",", "", pdat$area)
pdat$pop2021 <- gsub(",", "", pdat$pop2021)
pdat$pdensity <- as.numeric(pdat$pop2021) / as.numeric(pdat$area)
turkey <- merge(turkey, pdat[, c("name_de", "pdensity")], on = "name_de")
ggplot(data = turkey) +
geom_sf(aes(fill = pdensity)) +
scale_fill_viridis_c(option = "plasma", trans = "log", direction = -1) +
theme_void() +
labs(title = "Population density in Turkey")
For map types, see https://leaflet-extras.github.io/leaflet-providers/preview/
# ESRI topographic
leaflet() %>%
addTiles(urlTemplate = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}") %>%
setView(35, 39, zoom = 5)
# Esri.WorldShadedRelief
leaflet() %>%
addTiles(urlTemplate = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}") %>%
setView(35, 39, zoom = 5)
# Two layers
leaflet(icons) %>%
setView(35, 39, zoom = 5) %>%
addTiles(group = "Map") %>%
addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
addFullscreenControl() %>%
addLayersControl(
baseGroups = c("Map", "Satellite"),
options = layersControlOptions(collapsed = FALSE)) %>%
hideGroup("Satellite")
# Popup icons and html content
c_1 <- '<iframe width="300" height="200" src="https://www.youtube.com/embed/wlgtuuyBmrw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
c_2 <- "METU Economics<br/><img src='http://econ.metu.edu.tr/system/files/home/predefined/gorselmedia_c.jpg' width=300px/>"
c_3 <- "<b><a href='http://econ.metu.edu.tr/'>METU Economics</a></b><br/>Ankara/Turkey"
c_4 <- '<iframe width="300" height="200" src="https://www.youtube.com/embed/iRkekjtnycc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
icons <- data.frame(lat = c(41.0, 37.0, 39.9, 40),
lon = c(28.9, 33.0, 32.8, 39),
labels = c("İş imkanları", "Mezuniyet", "ODTÜ İktisat", "Mezunlar"),
content = c(c_1, c_2, c_3, c_4))
leaflet(icons) %>%
addTiles(urlTemplate = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}") %>%
setView(35, 39, zoom = 5) %>%
addMarkers(~lon, ~lat, popup = ~content, label = ~as.character(labels))