# TRUE LAT/LNG Coordinates for Turkish Cities hosting IE Programs
tr_city_coords <- tibble(
City = c("Istanbul", "Ankara", "Izmir", "Bursa", "Eskisehir", "Antalya", "Konya", "Kocaeli", "Gaziantep", "Kayseri",
"Adana", "Sakarya", "Erzurum", "Samsun", "Diyarbakir", "Denizli", "Mersin", "Trabzon", "Balikesir", "Isparta",
"Karabuk", "Manisa", "Hatay", "Tekirdag", "Sivas", "Elazig", "Aydin", "Canakkale", "Yalova", "Zonguldak",
"Bolu", "Karaman", "Malatya", "Kutahya", "Kirikkale", "Tokat", "Afyonkarahisar", "Osmaniye", "Yozgat", "Duzce",
"Corum", "Giresun", "Nigde", "Mugla", "Isparta", "Edirne", "Rize", "Nevsehir", "Kastamonu", "Usak",
"Erzincan", "Kahramanmaras", "Sivas", "Gumushane", "Aksaray", "Kirklareli", "Burudur", "Bilecik", "Bartin", "Artvin"),
Lat = c(41.0082, 39.9334, 38.4192, 40.1824, 39.7767, 36.8969, 37.8667, 40.8533, 37.0662, 38.7312,
37.0000, 40.7569, 39.9000, 41.2867, 37.9144, 37.7765, 36.8000, 41.0015, 39.6484, 37.7648,
41.2061, 38.6191, 36.2000, 40.9833, 39.7477, 38.6810, 37.8444, 40.1553, 40.6500, 41.4564,
40.7359, 37.1811, 38.3552, 39.4167, 39.8468, 40.3167, 38.7507, 37.0742, 39.8210, 40.8438,
40.5506, 40.9128, 37.9658, 37.2153, 37.7648, 41.6744, 41.0201, 38.6244, 41.3781, 38.6823,
39.7500, 37.5858, 39.7477, 40.4600, 38.3687, 41.7333, 37.7167, 40.1451, 41.6344, 41.1828),
Lng = c(28.9784, 32.8597, 27.1287, 29.0669, 30.5206, 30.7133, 32.4833, 29.8815, 37.3833, 35.4787,
35.3213, 30.3783, 41.2700, 36.3300, 40.2306, 29.0864, 34.6333, 39.7178, 27.8826, 30.5566,
32.6222, 27.4289, 36.1667, 27.5167, 37.0179, 39.2225, 27.8458, 26.4142, 29.2667, 31.7987,
31.6061, 33.2222, 38.3095, 29.9833, 33.5134, 36.5500, 30.5367, 36.2478, 34.8044, 31.1565,
34.9556, 38.3897, 34.6793, 28.3636, 30.5566, 26.5557, 40.5234, 34.7144, 33.7753, 29.4082,
39.5000, 36.9371, 37.0179, 39.4817, 34.0297, 27.2167, 30.2833, 29.9793, 32.3375, 41.8183)
)
map_data <- ie_combined %>%
filter(Year == latest_year, Rank < 300000, City != "Not Specified") %>%
mutate(
# Cleaning city names for a perfect join
City = str_replace_all(str_to_upper(City), "İ", "I"),
City = str_replace_all(City, "Ş", "S"),
City = str_replace_all(City, "Ç", "C"),
City = str_replace_all(City, "Ğ", "G"),
City = str_replace_all(City, "Ü", "U"),
City = str_replace_all(City, "Ö", "O"),
City = str_to_title(City)
) %>%
group_by(City) %>%
summarise(
Avg_Rank = mean(Rank, na.rm = TRUE),
Total_Quota = sum(Quota, na.rm = TRUE),
Programs = n()
) %>%
left_join(tr_city_coords, by = "City") %>%
# Safe fallback to Central Turkey for unmapped edge-cases
mutate(
Lat = ifelse(is.na(Lat), 39.0, Lat),
Lng = ifelse(is.na(Lng), 35.0, Lng)
)
leaflet(map_data) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addCircleMarkers(
~Lng, ~Lat,
radius = ~sqrt(Total_Quota) * 0.8, # Scaled bubble size driven by quota capacity
color = ~ifelse(Avg_Rank < 50000, "#38bdf8", "#f472b6"), # Blue for elite, Pink for others
stroke = FALSE, fillOpacity = 0.7,
popup = ~paste("<b>", City, "</b><br>Active Programs:", Programs, "<br>Total Regional Quota:", Total_Quota, "<br>Avg Base Rank:", format(round(Avg_Rank), big.mark=".", scientific=FALSE))
)