1 Importazione dati

Le variabili del dataset di Missing Migrants

glimpse(orig)
## Observations: 5,144
## Variables: 22
## $ `Web ID`                              <dbl> 49252, 49251, 49246, 49249, 492…
## $ `Region of Incident`                  <chr> "US-Mexico Border", "US-Mexico …
## $ `Reported Date`                       <chr> "January 26, 2019", "January 25…
## $ `Reported Year`                       <dbl> 2019, 2019, 2019, 2019, 2019, 2…
## $ `Reported Month`                      <chr> "Jan", "Jan", "Jan", "Jan", "Ja…
## $ `Number Dead`                         <dbl> 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1…
## $ `Minimum Estimated Number of Missing` <dbl> NA, NA, NA, NA, NA, NA, NA, NA,…
## $ `Total Dead and Missing`              <dbl> 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1…
## $ `Number of Survivors`                 <dbl> NA, NA, 2, NA, NA, NA, NA, NA, …
## $ `Number of Females`                   <dbl> NA, NA, NA, 1, NA, NA, NA, 1, N…
## $ `Number of Males`                     <dbl> 1, 1, 1, 1, 1, 1, 1, NA, 1, 1, …
## $ `Number of Children`                  <dbl> NA, NA, NA, 1, NA, NA, NA, NA, …
## $ `Cause of Death`                      <chr> "Presumed drowning", "Presumed …
## $ `Location Description`                <chr> "Río Bravo, near Centro Recreat…
## $ `Information Source`                  <chr> "El Mañana, Vox Pópuli", "La Ta…
## $ lat                                   <dbl> 26.14306, 26.21724, 35.38452, 3…
## $ lon                                   <dbl> -98.3301648, -98.4553935, -1.27…
## $ `Migration Route`                     <fct> NA, NA, Western Mediterranean, …
## $ URL                                   <chr> "https://bit.ly/2FSKun9, https:…
## $ `UNSD Geographical Grouping`          <chr> "Central America", "Central Ame…
## $ `Source Quality`                      <int> 3, 1, 3, 3, 3, 3, 3, 1, 4, 3, 3…
## $ date                                  <chr> "January 26, 2019", "January 25…

1.1 I valori mancanti

Una componente da tenere in considerazione quando si esplora un datase è il conteggio dei missing values

Utilizzare tabelle di contingenza ci aiuta a trovare in maniera semplice la relazione tra le variabili

    orig %>%
   mutate(route_na=ifelse(is.na(`Migration Route` ), "unknow", "know")) %>%
   select( `Source Quality`, route_na) %>%
   table() %>%
   addmargins()
##               route_na
## Source Quality know unknow  Sum
##            1    700    187  887
##            2      3   1662 1665
##            3    310    142  452
##            4    585    327  912
##            5    936     36  972
##            Sum 2534   2354 4888

2 Analisi esplorativa attraverso la visualizzazione geografica

Trasformiamo il data.frame in un oggetto geografico. Il package sf è estramente versatile e semplice da utilizzare per qualunque funzione di geoprocessing

Ora possiamo visualizzare su mappa la distrubuzione geografica degli eventi che caratterizzano il fenomeno

tm_shape(World, unit = "km")+
tm_polygons(col = "#333333")+
tm_shape(data_geo)+
tm_dots(col = "Migration Route",
         pal="Set1",
         size=0.1)+
  tm_layout(legend.outside=T)

mapview(data_geo,
               zcol="Migration Route",
                legend=F)
tm_shape(World, unit = "km")+
tm_polygons(col = "#333333")+
tm_shape(data_geo)+
tm_dots(col = "Migration Route",
         pal="Set1",
        legend.show = F,
         size=0.2)+
  tm_facets("Migration Route")

Oltre ai missing values il dataset è purtroppo ricco di errori

medi <- filter(data_geo, `Migration Route`=="Eastern Mediterranean"|`Migration Route`=="Western Mediterranean"|`Migration Route`=="Central Mediterranean")

tm_shape(World %>% st_transform(4326),unit = "km", bbox = tmaptools::bb(medi))+
tm_polygons(col = "#333333")+
tm_shape(medi)+
tm_dots(col = 'Migration Route',
        pal="Set1",
        legend.show = F,
        size=0.2)

# tmap_mode("plot")

3 Una analisi per sulle rotte

Per osservare meglio i dati sulle rotte è utile trasformare le nuvole di punti in aree con convex hull

conv_routes <- data %>% 
                   filter(!is.na(`route`)) %>% 
                   group_by(`route`) %>% 
                   summarise() %>% 
                   st_convex_hull()
tm_shape(World, unit = "km")+
tm_polygons(col = "#333333")+
tm_shape(conv_routes)+
  tm_polygons(col="route")

Ci sono alcuni problemi di sovrapposizione e rotte che hanno solo una osservazione

mapview(conv_routes, zcol="route")+
  mapview(data, zcol="route")
conv_routes <-
  data %>% 
  filter(!is.na(route)) %>% 
  group_by(route) %>% 
  summarise() %>% 
  st_convex_hull() %>% 
  st_difference()



conv_routes2 <-
  conv_routes %>%
  filter(st_is(.,c("LINESTRING", "POINT"))) %>% #aggiungere calcolo st_area
  st_buffer(dist=4.5, nQuadSegs = 2) %>%
  st_difference() 
## Warning in st_buffer.sfc(st_geometry(x), dist, nQuadSegs, endCapStyle =
## endCapStyle, : st_buffer does not correctly buffer longitude/latitude data
## dist is assumed to be in decimal degrees (arc_degrees).
conv_routes <- conv_routes %>% 
  filter(st_is(.,c("POLYGON"))) %>%
  rbind(conv_routes2)
mapview(conv_routes, zcol="route")+
  mapview(data, zcol="route")