athowes / beyond-borders

Evaluating the suitability of spatial adjacency for small-area estimation
https://athowes.github.io/beyond-borders
MIT License
2 stars 1 forks source link

Sort out the Tanzania islands issue from last time #32

Closed athowes closed 7 months ago

athowes commented 2 years ago

Remove islands?

  nb <- sf_to_nb(tz) # Neighbourhood list
  comp <- spdep::n.comp.nb(nb) # Connected components
  table(comp$comp.id) # The number of districts in each component
  is_mainland <- comp$comp.id == 1
  tz_no_islands <- tz[is_mainland, ] # Only those on the mainland
  tz_no_islands$survey_id <- "TZ2012AIS-no-islands" # Change the ID so that fit_id works