Week 6 Demo: Finding and Using Datasets for Final Projects

PPOL 6805: GIS for Spatial Data Science

Workshop Sessions
Author

Christy Hsu

Published

September 30, 2026

Note 1: Bringing Point Data in Place

This demo is meant to provide a walkthrough that people might find relevant as they begin looking for potential datasets for their final project, especially in showing what steps to take when spatial data appears off during the EDA phase.

For illustration, I will be using the replication data for Steven Brooke and Neil Ketchley’s 2018 paper “Social and Institutional Origins of Political Islam” downloaded from dataverse (Brooke and Ketchley (2018))

The 2018 study associated the Muslim Brotherhood branches in Interwar Egypt (204 branches in 1937 and 238 in 1940) with the 4230 subdistricts from the 1937 census appendices. Therefore, each row, or a point, in this dataset represents a subdistrict, where there are variables such as population characteristics, presence of Muslim Brotherhood branches, presence of state railway stations, and other attributes that describes the subdistrict.1

Read and Count: understanding the Unit(s) of Observation of our dataset

Now we get the sense that though we have data on subdistricts, yet the granularity for the spatial variable is only at administrative level 2 (disrict or qism)

We would like to start with understanding the unit of observation of our dataset, and we especially wanted to look into how these observations are represented spatially in the data that we have.

Note

Egypt subnational divisions

  • Governoratemuhafatha (administrative level 1)
  • District: Qism (level 2), 142 qisms
  • Subdistrict: Subdistrict Name (level 3)2
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.2     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
library(mapview)
library(rnaturalearth)
library(viridis)
Loading required package: viridisLite
eg_subdistrict_df <- read_csv('data/mb-interwar-egypt-decoded.csv')
Rows: 4230 Columns: 40
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (3): muhafatha, qism, name
dbl (37): mb_1940, mb_1937, total_population, male_total, male_foreigners, m...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
eg_subdistrict_df |> dim() |> print()
[1] 4230   40
eg_subdistrict_df |> head()
muhafatha qism name mb_1940 mb_1937 total_population male_total male_foreigners male_moslem male_copt male_other_religions female_foreigners female_moslem female_copt female_other_religions male_farmers_fishermen_and_hunti male_without_occupations female_farmers_fishermen_and_hun male_age_5_and_above_read_and_wr male_age_5_and_above_illiterate female_age_5_and_above_read_and_ female_age_5_and_above_illiterat founder_governorate founder_district _total_gov_employees _population_over_5 pop_1917 greek french british italian admin_centre district_total_pop total_missionaries district_X district_Y state_railway_station british_military_base_1926 barracks_capacity_1926 british_military_base_1937
Asyut Abnub Gazirat Bahig 0 0 3142 1638 0 1543 94 1 0 1426 78 0 1084 169 48 150 1271 47 1192 0 0 603 111199 101206 0 0 2 0 0 127499 0 31.14603 27.26193 0 0 0 0
Asyut Abnub Arab al-Atiyat al-bahriyya 0 0 2151 1188 0 1104 84 0 0 896 67 0 795 132 2 156 940 30 837 0 0 603 111199 101206 0 0 2 0 0 127499 0 31.14603 27.26193 0 0 0 0
Asyut Abnub Dayr Bisra 0 0 334 181 0 0 181 0 0 0 153 0 111 4 1 65 95 5 116 0 0 603 111199 101206 0 0 2 0 0 127499 0 31.14603 27.26193 0 0 0 0
Asyut Abnub Bani Murr 0 0 3256 1660 0 1343 317 0 0 1314 282 0 920 182 16 305 1146 82 1278 0 0 603 111199 101206 0 0 2 0 0 127499 0 31.14603 27.26193 0 0 0 0
Asyut Abnub Qasr 0 0 1628 835 0 814 21 0 0 768 25 0 600 83 45 101 664 31 672 0 0 603 111199 101206 0 0 2 0 0 127499 0 31.14603 27.26193 0 0 0 0
Asyut Abnub Sawalim Abnub 0 1 1542 790 0 750 40 0 0 710 42 0 466 15 157 236 442 88 550 0 0 603 111199 101206 0 0 2 0 0 127499 0 31.14603 27.26193 0 0 0 0
mb_df <- eg_subdistrict_df |>
  filter(mb_1940 + mb_1940 > 0)
mb_df |> count(district_X) |> dim()
[1] 91  2
set.seed(103)
eg_subdistrict_df |> slice_sample(n = 6)
muhafatha qism name mb_1940 mb_1937 total_population male_total male_foreigners male_moslem male_copt male_other_religions female_foreigners female_moslem female_copt female_other_religions male_farmers_fishermen_and_hunti male_without_occupations female_farmers_fishermen_and_hun male_age_5_and_above_read_and_wr male_age_5_and_above_illiterate female_age_5_and_above_read_and_ female_age_5_and_above_illiterat founder_governorate founder_district _total_gov_employees _population_over_5 pop_1917 greek french british italian admin_centre district_total_pop total_missionaries district_X district_Y state_railway_station british_military_base_1926 barracks_capacity_1926 british_military_base_1937
Gharbiyya Zifta Zifta (dakhil al-kurdun) wa-kafr Inan 1 1 23952 11830 90 11097 635 98 84 11415 611 96 2488 1414 847 3937 6102 1345 8979 1 0 1043 135686 147987 132 18 12 3 0 156159 1 31.20618 30.73269 1 0 0 0
Giza Giza Gazirat al-Dahab 0 0 3523 1686 0 1629 57 0 0 1783 54 0 691 207 132 221 1250 78 1490 0 0 1245 134725 115449 124 111 152 15 0 156390 0 29.40750 31.17278 0 0 0 0
Girga Akhmim Saqulta wa-l-Arab 0 0 5342 2747 0 2559 188 0 1 2437 157 1 1393 336 729 549 1844 133 2055 0 0 675 106698 94942 0 0 0 0 0 124663 2 31.71509 26.62262 0 0 0 0
Girga Tima Kum al-Hamid 0 0 1030 525 0 450 75 0 0 450 55 0 354 53 68 58 404 18 435 0 0 664 113506 101882 12 0 2 0 0 130843 0 31.42511 26.86811 0 0 0 0
Buhayra Kum Hamada Zawiyyat Firig 0 0 2805 1319 0 1173 128 18 0 1338 131 17 360 118 180 445 719 145 1171 1 0 863 146628 158766 40 11 3 0 0 165740 0 30.73368 30.67402 0 0 0 0
Giza Ayyat Zawiyyat Dahshur 0 0 4679 2407 0 2399 8 0 0 2265 7 0 1533 282 245 220 1901 87 1868 0 0 600 128299 117189 10 7 3 4 0 146866 2 31.24063 29.57391 0 0 0 0
eg_subdistrict_df |> filter(mb_1937 + mb_1940 > 0) |> dim()
[1] 326  40
eg_subdistrict_df |>
  group_by(qism) |>
  summarize(
    coords_count = n_distinct(district_X)
  )
qism coords_count
Abdin 1
Abnub 1
Abu Hummus 1
Abu Qurqas 1
Abu Tig 1
Abu al-Matamir 1
Aga 1
Akhmim 1
Ashmun 1
Aswan 1
Asyut 1
Attarin 1
Ayyat 1
Azbakiyya 1
Bab al-Shariyya 1
Badari 1
Balyana 1
Bandar Aswan 1
Bandar Asyut 1
Bandar Banha 1
Bandar Bani Suwayf 1
Bandar Damanhur 1
Bandar Fayyum 1
Bandar Giza 1
Bandar Hulwan 1
Bandar Mahalla al-Kubra 1
Bandar Mansura 1
Bandar Minya 1
Bandar Qina 1
Bandar Shibin al-Kum 1
Bandar Suhag 1
Bandar Tanta 1 1
Bandar Tanta 2 1
Bandar Zaqaziq 1
Banha 1
Bani Mazar 1
Bani Suwayf 1
Barrani 1
Biba 1
Bilbays 1
Bulaq 1
Burullus 1
Daba 1
Damanhur 1
Darb al-Ahmar 1
Dawahi Misr 1
Dayrut 1
Dikirnis 1
Dilingat 1
Dishna 1
Disuq 1
Dumyat 1
Durr 1
Faqus 1
Fariskur 1
Fashn 1
Fayyum 1
Fuwwa 1
Gamaliyya 1
Ghardaqa 1
Girga 1
Giza 1
Gumruk 1
Hammam 1
Hihya 1
Ibshaway 1
Idfu 1
Imbaba 1
Ismailliyya 1
Isna 1
Itsa 1
Ityay al-Barud 1
Kafr Saqr 1
Kafr al-Dawwar 1
Kafr al-Shaykh 1
Kafr al-Zayyat 1
Karmuz 1
Khalifa 1
Khalig al-Suways 1
Kum Hamada 1
Labban 1
Maghagha 1
Mahalla al-Kubra 1
Mahmudiyya 1
Mallawi 1
Manfalut 1
Manshiyya 1
Mansura 1
Mantiqa al-Wusta 1
Manzala 1
Marsa Matruh 1
Mina 1
Mina al-Basal 1
Minuf 1
Minya 1
Minya al-Qamh 1
Misr al-Gadida 1
Misr al-Qadima 1
Mit Ghamr 1
Muharram bey 1
Muski 1
Nag Hammadi 1
Port Said (qism 1) 1
Qalyub 1
Qantara sharq 1
Qina 1
Qism al-Sharq (Maryut) 1
Qus 1
Qusayr 1
Quwisna 1
Raml 1
Rashid 1
Saff 1
Sallum 1
Samallut 1
Samannud 1
Santa 1
Sayyida Zaynab 1
Shibin al-Kum 1
Shibin al-Qanatir 1
Shirbin 1
Shubra gharb 1
Shubra sharq 1
Shubrakhit 1
Sina al-mutawassit 1
Sina al-shimali 1
Sina“ al-ganubi 1
Sinballawayn 1
Sinuris 1
Siwa 1
Suhag 1
Suways 1
Tahta 1
Tala 1
Talkha 1
Tanta 1
Tima 1
Tukh 1
Uqsur (Luxor) 1
Wahat al-bahriyya 1
Wahat al-dakhla 1
Wahat al-kharga 1
Wasta 1
Wayli 1
Zaqaziq 1
Zifta 1
eg_subdistrict_df |> filter(is.na(district_X))
muhafatha qism name mb_1940 mb_1937 total_population male_total male_foreigners male_moslem male_copt male_other_religions female_foreigners female_moslem female_copt female_other_religions male_farmers_fishermen_and_hunti male_without_occupations female_farmers_fishermen_and_hun male_age_5_and_above_read_and_wr male_age_5_and_above_illiterate female_age_5_and_above_read_and_ female_age_5_and_above_illiterat founder_governorate founder_district _total_gov_employees _population_over_5 pop_1917 greek french british italian admin_centre district_total_pop total_missionaries district_X district_Y state_railway_station british_military_base_1926 barracks_capacity_1926 british_military_base_1937
Bahr al-Ahmar Khalig al-Suways Zafarana (incl. GharibZaytiyyaDayr) 0 0 214 159 6 101 52 6 2 52 0 3 15 25 1 83 68 6 39 0 0 103 698 NA 2 5 0 1 0 764 0 NA NA 0 0 0 0
Bahr al-Ahmar Khalig al-Suways Bi“r Udayb wa-l-Atka wa-ghubbat al-Bus wa-l-Gamasa 0 0 550 440 4 431 5 4 0 105 4 1 52 28 0 40 369 1 92 0 0 103 698 NA 2 5 0 1 0 764 0 NA NA 0 0 0 0
Bahr al-Ahmar Mantiqa al-Wusta Cairo-Suez Road 0 0 143 90 0 86 4 0 0 44 9 0 2 13 0 19 57 1 40 0 0 35 117 NA 0 0 0 0 0 143 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Qism al-Sharq (Maryut) Wadi al-Natrun wa-l-Adyira wa-Bir Hukar 0 0 2361 1292 6 1209 74 9 6 1064 0 5 117 422 4 210 917 9 908 0 0 88 4025 NA 0 8 0 42 0 7698 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Qism al-Sharq (Maryut) Amiriyya 0 1 1296 645 17 634 11 0 17 639 12 0 156 149 13 210 355 26 506 0 0 88 4025 NA 0 8 0 42 0 7698 0 NA NA 1 0 0 0
Sahara“ al-gharbiyya Qism al-Sharq (Maryut) Mirghib wa-Abd al-Qadir wa-Mikwariyya 0 0 1421 708 7 704 4 0 7 709 4 0 436 143 37 15 592 1 606 0 0 88 4025 NA 0 8 0 42 0 7698 0 NA NA 1 0 0 0
Sahara“ al-gharbiyya Qism al-Sharq (Maryut) Ikingi Maryut wa-l-Dirisa 0 0 746 437 2 435 0 2 0 308 0 1 188 138 12 20 358 2 257 0 0 88 4025 NA 0 8 0 42 0 7698 0 NA NA 1 0 0 0
Sahara“ al-gharbiyya Qism al-Sharq (Maryut) Umm Zaghyu wa-Sidi Krir wa-l-Hawwariyya 0 0 1170 593 0 592 1 0 0 577 0 0 388 112 1 18 498 3 504 0 0 88 4025 NA 0 8 0 42 0 7698 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Qism al-Sharq (Maryut) Agami wa-l-Dira al-bahri wa-l Dayr 0 0 704 378 0 378 0 0 0 326 0 0 239 78 8 4 314 0 281 0 0 88 4025 NA 0 8 0 42 0 7698 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Wahat al-bahriyya Bawiti 0 0 1748 924 0 916 8 0 0 820 4 0 465 174 7 138 708 8 754 0 0 78 3218 6497 0 0 0 0 0 4720 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Wahat al-bahriyya Zabw 0 0 794 414 0 414 0 0 0 380 0 0 242 88 0 18 342 0 325 0 0 78 3218 6497 0 0 0 0 0 4720 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Wahat al-bahriyya Farafra 0 0 674 352 0 351 1 0 0 322 0 0 222 59 4 29 273 0 278 0 0 78 3218 6497 0 0 0 0 0 4720 0 NA NA 0 0 0 0
Sahara“ al-gharbiyya Wahat al-bahriyya Qasr 0 0 1504 788 0 788 0 0 0 716 0 0 418 182 9 80 597 0 584 0 0 78 3218 6497 0 0 0 0 0 4720 0 NA NA 0 0 0 0
eg_subdistrict_df |> filter(qism == '
Qism al-Sharq (Maryut)') |> filter(is.na(district_X))
muhafatha qism name mb_1940 mb_1937 total_population male_total male_foreigners male_moslem male_copt male_other_religions female_foreigners female_moslem female_copt female_other_religions male_farmers_fishermen_and_hunti male_without_occupations female_farmers_fishermen_and_hun male_age_5_and_above_read_and_wr male_age_5_and_above_illiterate female_age_5_and_above_read_and_ female_age_5_and_above_illiterat founder_governorate founder_district _total_gov_employees _population_over_5 pop_1917 greek french british italian admin_centre district_total_pop total_missionaries district_X district_Y state_railway_station british_military_base_1926 barracks_capacity_1926 british_military_base_1937
eg_subdistrict_sf <- eg_subdistrict_df |> filter(!is.na(district_X)) |> st_as_sf(coords = c('district_X', 'district_Y'), crs = 4326)
eg_subdistrict_sf |>
  count(qism) |>
  mapview(label = 'muhafatha')
eg_subdistrict_sf |> filter(muhafatha == 'al-Qahira') |> count(name) |> tail()
name n geometry
Zamalik al-qibliyya 1 POINT (31.2451 30.04572)
Zawiyya al-Hamra 1 POINT (31.24721 30.09319)
Zaynhum 1 POINT (31.24251 30.03083)
Zaytun al-gharbiyya 1 POINT (31.32245 30.08976)
Zaytun al-qibliyya 1 POINT (31.32245 30.08976)
Zaytun al-sharqiyya 1 POINT (31.32245 30.08976)
egypt_sf <- ne_countries(country = 'Egypt', scale = 50) |> select(geounit)

Case: preserving the coords

eg_subdistrict_sf <- eg_subdistrict_sf |>
  mutate(
    longitude = format(st_coordinates(geometry)[, 1], digits = 12),
    latitude = format(st_coordinates(geometry)[, 2], digits = 12)
  )
eg_subdistrict_sf |> select(name, longitude, latitude) |> slice_sample(n = 5)
name longitude latitude geometry
Gamaliyya wa-kafr-ha 31.9382798198 31.1522718359 POINT (31.93828 31.15227)
Gazirat al-Kuraymat 31.2964514035 29.6267505022 POINT (31.29645 29.62675)
Kafr Abu Zahra 30.4255555556 31.2116666667 POINT (30.42556 31.21167)
Zahhar 31.2468819188 30.0590403534 POINT (31.24688 30.05904)
Daba wa-Fuka wa-Ghazal 28.2120000387 29.8153551044 POINT (28.212 29.81536)

Case: st_intersects() as a spatial filter

intersect_list <- st_intersects(eg_subdistrict_sf, egypt_sf)
intersect_list |> class()
[1] "sgbp" "list"
eg_subdistrict_sf$n_intersections <- lengths(intersect_list)
eg_subdistrict_sf |>
  filter(n_intersections < 1) |> mapview()

flip_lonlat() Function

flip_lonlat <- function(geom) {
    old_coords <- st_coordinates(geom)

    st_point(c(old_coords[2], old_coords[1]))
}
flipped_sf <- eg_subdistrict_sf |>
  filter(n_intersections < 1) |>
  mutate(geometry = map(geometry, flip_lonlat) |>
  st_sfc(crs = 4326))
flipped_sf |> mapview()
flipped_sf |> select(longitude, latitude) |> slice_sample(n = 4)
longitude latitude geometry
29.4075000000 31.1727777778 POINT (31.17278 29.4075)
30.5941666667 32.3027777778 POINT (32.30278 30.59417)
29.8735910960 31.1983294747 POINT (31.19833 29.87359)
29.8735910960 31.1983294747 POINT (31.19833 29.87359)
  • sanity check here, Rafah crossing, Ismailiya, Giza and Port Said, at a quick look everything seems to be in place
flipped_sf |> st_crs()
Coordinate Reference System:
  User input: EPSG:4326 
  wkt:
GEOGCRS["WGS 84",
    ENSEMBLE["World Geodetic System 1984 ensemble",
        MEMBER["World Geodetic System 1984 (Transit)"],
        MEMBER["World Geodetic System 1984 (G730)"],
        MEMBER["World Geodetic System 1984 (G873)"],
        MEMBER["World Geodetic System 1984 (G1150)"],
        MEMBER["World Geodetic System 1984 (G1674)"],
        MEMBER["World Geodetic System 1984 (G1762)"],
        MEMBER["World Geodetic System 1984 (G2139)"],
        MEMBER["World Geodetic System 1984 (G2296)"],
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]],
        ENSEMBLEACCURACY[2.0]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["Horizontal component of 3D system."],
        AREA["World."],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]
flipped_sf |>
  ggplot() + 
  geom_sf()

Case: Update

flipped_sf <- flipped_sf |>
  mutate(
    old_lon = longitude,
    longitude = latitude,
    latitude = old_lon
  ) |>
  select(-old_lon)

flipped_sf |> select(longitude, latitude) |> slice_sample(n = 4)
longitude latitude geometry
31.1727777778 29.4075000000 POINT (31.17278 29.4075)
34.8955555556 29.4919444444 POINT (34.89556 29.49194)
32.3027777778 30.5941666667 POINT (32.30278 30.59417)
34.8955555556 29.4919444444 POINT (34.89556 29.49194)
flipped_sf |> mapview(label = 'qism')
valid_sf <- eg_subdistrict_sf |>
  filter(n_intersections > 0)
valid_sf |> dim()
[1] 4122   42
fixed_subdistrict_sf <- bind_rows(valid_sf, flipped_sf)
fixed_subdistrict_sf |> count(qism) |> mapview(label = 'muhafatha')
fixed_subdistrict_sf |> summary()
  muhafatha             qism               name              mb_1940       
 Length:4217        Length:4217        Length:4217        Min.   :0.00000  
 Class :character   Class :character   Class :character   1st Qu.:0.00000  
 Mode  :character   Mode  :character   Mode  :character   Median :0.00000  
                                                          Mean   :0.05644  
                                                          3rd Qu.:0.00000  
                                                          Max.   :1.00000  
                                                                           
    mb_1937        total_population   male_total    male_foreigners  
 Min.   :0.00000   Min.   :    0    Min.   :    0   Min.   :   0.00  
 1st Qu.:0.00000   1st Qu.: 1462    1st Qu.:  713   1st Qu.:   0.00  
 Median :0.00000   Median : 2625    Median : 1296   Median :   0.00  
 Mean   :0.04814   Mean   : 3772    Mean   : 1887   Mean   :  21.61  
 3rd Qu.:0.00000   3rd Qu.: 4721    3rd Qu.: 2348   3rd Qu.:   0.00  
 Max.   :1.00000   Max.   :68887    Max.   :34702   Max.   :5812.00  
                                                                     
  male_moslem      male_copt     male_other_religions female_foreigners
 Min.   :    0   Min.   :    0   Min.   :   0.00      Min.   :   0.0   
 1st Qu.:  667   1st Qu.:    1   1st Qu.:   0.00      1st Qu.:   0.0   
 Median : 1212   Median :   12   Median :   0.00      Median :   0.0   
 Mean   : 1724   Mean   :  131   Mean   :  32.35      Mean   :  22.6   
 3rd Qu.: 2203   3rd Qu.:   74   3rd Qu.:   0.00      3rd Qu.:   0.0   
 Max.   :30338   Max.   :10476   Max.   :8684.00      Max.   :6622.0   
                                                                       
 female_moslem    female_copt     female_other_religions
 Min.   :    0   Min.   :   0.0   Min.   :   0.00       
 1st Qu.:  686   1st Qu.:   0.0   1st Qu.:   0.00       
 Median : 1236   Median :  11.0   Median :   0.00       
 Mean   : 1724   Mean   : 126.3   Mean   :  34.69       
 3rd Qu.: 2203   3rd Qu.:  71.0   3rd Qu.:   0.00       
 Max.   :29436   Max.   :9956.0   Max.   :9793.00       
                                                        
 male_farmers_fishermen_and_hunti male_without_occupations
 Min.   :    0.0                  Min.   :   0.0          
 1st Qu.:  325.0                  1st Qu.:  56.0          
 Median :  653.0                  Median : 126.0          
 Mean   :  854.2                  Mean   : 209.8          
 3rd Qu.: 1154.0                  3rd Qu.: 245.0          
 Max.   :10655.0                  Max.   :5315.0          
                                                          
 female_farmers_fishermen_and_hun male_age_5_and_above_read_and_wr
 Min.   :   0.0                   Min.   :    0.0                 
 1st Qu.:  10.0                   1st Qu.:  110.0                 
 Median :  59.0                   Median :  226.0                 
 Mean   : 166.7                   Mean   :  447.1                 
 3rd Qu.: 222.0                   3rd Qu.:  441.0                 
 Max.   :2409.0                   Max.   :20422.0                 
                                                                  
 male_age_5_and_above_illiterate female_age_5_and_above_read_and_
 Min.   :    0                   Min.   :   0.0                  
 1st Qu.:  468                   1st Qu.:  30.0                  
 Median :  862                   Median :  65.0                  
 Mean   : 1198                   Mean   : 162.1                  
 3rd Qu.: 1514                   3rd Qu.: 130.0                  
 Max.   :18105                   Max.   :9382.0                  
                                                                 
 female_age_5_and_above_illiterat founder_governorate founder_district 
 Min.   :    0                    Min.   :0.0000      Min.   :0.00000  
 1st Qu.:  589                    1st Qu.:0.0000      1st Qu.:0.00000  
 Median : 1060                    Median :0.0000      Median :0.00000  
 Mean   : 1465                    Mean   :0.3118      Mean   :0.03083  
 3rd Qu.: 1844                    3rd Qu.:1.0000      3rd Qu.:0.00000  
 Max.   :22423                    Max.   :1.0000      Max.   :1.00000  
                                                                       
 _total_gov_employees _population_over_5    pop_1917          greek        
 Min.   :  13         Min.   :   761     Min.   :   623   Min.   :    0.0  
 1st Qu.: 709         1st Qu.:109088     1st Qu.:100701   1st Qu.:   12.0  
 Median : 941         Median :134725     Median :132868   Median :   33.0  
 Mean   :1105         Mean   :137403     Mean   :135033   Mean   :  208.2  
 3rd Qu.:1365         3rd Qu.:174334     3rd Qu.:164472   3rd Qu.:   69.0  
 Max.   :6833         Max.   :237572     Max.   :411898   Max.   :13445.0  
                                         NA's   :33                        
     french           british           italian        admin_centre    
 Min.   :   0.00   Min.   :   0.00   Min.   :   0.0   Min.   :0.00000  
 1st Qu.:   0.00   1st Qu.:   1.00   1st Qu.:   1.0   1st Qu.:0.00000  
 Median :   2.00   Median :   3.00   Median :   4.0   Median :0.00000  
 Mean   :  67.29   Mean   :  98.59   Mean   : 150.9   Mean   :0.02822  
 3rd Qu.:  18.00   3rd Qu.:   8.00   3rd Qu.:  15.0   3rd Qu.:0.00000  
 Max.   :2165.00   Max.   :4985.00   Max.   :8349.0   Max.   :1.00000  
                                                                       
 district_total_pop total_missionaries state_railway_station
 Min.   :   847     Min.   : 0.000     Min.   :0.0000       
 1st Qu.:124482     1st Qu.: 0.000     1st Qu.:0.0000       
 Median :156509     Median : 1.000     Median :0.0000       
 Mean   :158585     Mean   : 1.841     Mean   :0.0913       
 3rd Qu.:200369     3rd Qu.: 2.000     3rd Qu.:0.0000       
 Max.   :273657     Max.   :67.000     Max.   :1.0000       
                                                            
 british_military_base_1926 barracks_capacity_1926 british_military_base_1937
 Min.   :0.00000            Min.   :   0.00        Min.   :0.00000           
 1st Qu.:0.00000            1st Qu.:   0.00        1st Qu.:0.00000           
 Median :0.00000            Median :   0.00        Median :0.00000           
 Mean   :0.03344            Mean   :  42.42        Mean   :0.03249           
 3rd Qu.:0.00000            3rd Qu.:   0.00        3rd Qu.:0.00000           
 Max.   :1.00000            Max.   :3930.00        Max.   :1.00000           
                                                                             
  longitude           latitude         n_intersections           geometry   
 Length:4217        Length:4217        Min.   :0.0000   POINT        :4217  
 Class :character   Class :character   1st Qu.:1.0000   epsg:4326    :   0  
 Mode  :character   Mode  :character   Median :1.0000   +proj=long...:   0  
                                       Mean   :0.9775                       
                                       3rd Qu.:1.0000                       
                                       Max.   :1.0000                       
                                                                            
fixed_subdistrict_sf |> count(qism, latitude, longitude) |> slice_sample(n = 10)
qism latitude longitude n geometry
Dishna 26.1415364212 32.4521515901 17 POINT (32.45215 26.14154)
Banha 31.2116666667 30.4255555556 40 POINT (30.42556 31.21167)
Santa 30.7458440000 31.1067280000 55 POINT (31.10673 30.74584)
Suhag 26.5586210174 31.6831132124 49 POINT (31.68311 26.55862)
Dawahi Misr 30.0827450000 31.2760470000 7 POINT (31.27605 30.08274)
Mansura 31.0336540485 31.4665244084 65 POINT (31.46652 31.03365)
Barrani 30.5129737001 25.8888016118 1 POINT (25.8888 30.51297)
Ityay al-Barud 30.8875879413 30.6579556875 57 POINT (30.65796 30.88759)
Bani Mazar 28.4892190000 30.7524060000 56 POINT (30.75241 28.48922)
Muharram bey 31.1848081714 29.9359493054 9 POINT (29.93595 31.18481)
fixed_subdistrict_sf |> count(qism, latitude, longitude) |> dim()
[1] 142   5
fixed_subdistrict_sf |> arrange(desc(greek)) |> head(10) |> mapview()
fixed_subdistrict_sf |> filter(muhafatha == 'al-Qahira') |> arrange(desc(french)) |> head(10) |> mapview()

References

Brooke, Steven, and Neil Ketchley. 2018. “Social and Institutional Origins of Political Islam.” American Political Science Review 112 (2): 376–94.

Footnotes

  1. some variables are attributes of divisions a level higher↩︎

  2. There weren’t more than one presence of MB branches in a subdistrict, thus of the 4000 subdistrict, each can be mark as presence or absence of MB branch↩︎