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
Remove islands?