Goal

The article describes the visualization of air-crash data with the help of map. The data is hosted by the National Transportation Safety Board (NTSB) of USA, a specialized federal wing that is assigned the task of investigating accidents in road, air, water and pipeline. Apart from this, it also documents the cases and issues advisories to ensure and enhance transportation safety. The data used here can be downloaded from NTSB official website.

The Data

Below is a summary of the original imported dataset.

##             Event.Id      Investigation.Type     Accident.Number 
##  20001212X19172 :    3    Accident :75722     ANC00FA018 :    1  
##  20001214X45071 :    3    Incident : 3160     ANC00FA024 :    1  
##  20100204X45658 :    3                        ANC00FA052 :    1  
##  20101022X34140 :    3                        ANC00FA056 :    1  
##  20001204X00086 :    2                        ANC00FA076 :    1  
##  20001205X00276 :    2                        ANC00FA081 :    1  
##  (Other)        :78866                       (Other)     :78876  
##         Event.Date                 Location                 Country     
##   05/16/1982 :   25    ANCHORAGE. AK   :  372    United States  :74421  
##   06/30/1984 :   25    MIAMI. FL       :  185                   :  507  
##   07/08/2000 :   25    CHICAGO. IL     :  169    Canada         :  245  
##   05/17/1986 :   24    ALBUQUERQUE. NM :  165    Brazil         :  213  
##   06/05/1983 :   24    HOUSTON. TX     :  155    Mexico         :  209  
##   08/05/1983 :   24    FAIRBANKS. AK   :  138    United Kingdom :  208  
##  (Other)     :78735   (Other)          :77698   (Other)         : 3079  
##     Latitude        Longitude        Airport.Code  
##  Min.   :-78.02   Min.   :-178.68          :34329  
##  1st Qu.: 33.40   1st Qu.:-115.02    NONE  : 1462  
##  Median : 38.17   Median : -94.53    PVT   :  354  
##  Mean   : 37.71   Mean   : -93.81    ORD   :  146  
##  3rd Qu.: 42.56   3rd Qu.: -81.75    APA   :  141  
##  Max.   : 89.22   Max.   : 177.56    MRI   :  125  
##  NA's   :53509    NA's   :53518     (Other):42325  
##              Airport.Name      Injury.Severity       Aircraft.Damage 
##                    :29991    Non-Fatal :59746                : 2395  
##   N/A              : 1669    Fatal(1)  : 7770    Destroyed   :17242  
##   PRIVATE          :  215    Fatal(2)  : 4585    Minor       : 2511  
##   Private          :  171    Incident  : 3160    Substantial :56734  
##   NONE             :  140    Fatal(3)  : 1435                        
##   Private Airstrip :  134    Fatal(4)  : 1003                        
##  (Other)           :46562   (Other)    : 1183                        
##     Aircraft.Category Registration.Number       Make      
##              :56857           : 3003       CESSNA :17004  
##   Airplane   :18875    NONE   :  364       PIPER  : 9370  
##   Helicopter : 2317    None   :  104       Cessna : 7742  
##   Glider     :  377    USAF   :    9       Piper  : 4096  
##   Balloon    :  172    N20752 :    8       BEECH  : 3113  
##   Gyrocraft  :  101    UNK    :    7       Beech  : 1748  
##  (Other)     :  183   (Other) :75387      (Other) :35809  
##          Model       Amateur.Built Number.of.Engines
##  152        : 2273        :  574   Min.   : 0.000   
##  172        : 1241    No  :70757   1st Qu.: 1.000   
##   172N      : 1130    Yes : 7551   Median : 1.000   
##   PA-28-140 :  900                 Mean   : 1.148   
##   172M      :  775                 3rd Qu.: 1.000   
##  150        :  722                 Max.   :18.000   
##  (Other)    :71841                 NA's   :4045     
##           Engine.Type                           FAR.Description 
##   Reciprocating :64202                                  :56936  
##                 : 3421    Part 91: General Aviation     :17632  
##   Turbo Shaft   : 3290    Part 137: Agricultural        : 1093  
##   Turbo Prop    : 3010    Non-U.S.. Non-Commercial      :  752  
##   Turbo Fan     : 2215    Part 135: Air Taxi & Commuter :  747  
##   Unknown       : 2050    Part 121: Air Carrier         :  525  
##  (Other)        :  694   (Other)                        : 1197  
##    Schedule                Purpose.of.Flight
##        :67399    Personal           :44337  
##   NSCH : 3852    Instructional      : 9442  
##   SCHD : 3532    Unknown            : 6789  
##   UNK  : 4099    Aerial Application : 4357  
##                  Business           : 3860  
##                                     : 3803  
##                 (Other)             : 6294  
##                   Air.Carrier    Total.Fatal.Injuries
##                         :74980   Min.   :  0.000     
##   UNITED AIRLINES       :   49   1st Qu.:  0.000     
##   AMERICAN AIRLINES     :   41   Median :  0.000     
##   CONTINENTAL AIRLINES  :   25   Mean   :  0.812     
##   SOUTHWEST AIRLINES CO :   24   3rd Qu.:  1.000     
##   USAIR                 :   24   Max.   :349.000     
##  (Other)                : 3739   NA's   :23019       
##  Total.Serious.Injuries Total.Minor.Injuries Total.Uninjured  
##  Min.   :  0.000        Min.   :  0.000      Min.   :  0.000  
##  1st Qu.:  0.000        1st Qu.:  0.000      1st Qu.:  0.000  
##  Median :  0.000        Median :  0.000      Median :  1.000  
##  Mean   :  0.316        Mean   :  0.501      Mean   :  5.794  
##  3rd Qu.:  0.000        3rd Qu.:  1.000      3rd Qu.:  2.000  
##  Max.   :111.000        Max.   :380.000      Max.   :699.000  
##  NA's   :25177          NA's   :24073        NA's   :12126    
##  Weather.Condition   Broad.Phase.of.Flight          Report.Status  
##       : 2127        LANDING     :19030      Factual        :  325  
##   IMC : 5647        TAKEOFF     :15171      Foreign        : 3875  
##   UNK :  957        CRUISE      :10709      Preliminary    : 1158  
##   VMC :70151        MANEUVERING : 9751      Probable Cause :73524  
##                     APPROACH    : 7673                             
##                                 : 6159                             
##                    (Other)      :10389                             
##      Publication.Date    X          
##              :13389   Mode:logical  
##   03/31/1993 :  453   NA's:78882    
##   11/25/2003 :  396                 
##   02/15/2001 :  377                 
##   09/13/2005 :  325                 
##   09/14/1993 :  312                 
##  (Other)     :63630

Filtering Data

The imported data is filtered as per the requirement of visualization. The filter function from dplyr comes in handy here. The data can be filtered with respect to column(s), most of which contain discrete values. This helps make meaningful inferences for various situations. For the purpose of simplicity, all the crash sites with investigation type ‘accident’ and damage ‘destroyed’ are used for visualization. Below is a sample code to filter data.

filter(Accidents, Investigation.Type == " Accident ")
filter(Accidents, Investigation.Type == " Accident ", Aircraft.Damage == " Destroyed ")
filter(Accidents, Investigation.Type == " Incident " | Aircraft.Damage == " Minor ")

Plotting Data

The maps are fetched from Google using methods from maps and ggmap package. The map of required location and suitable zoom are imported, onto which the coordinates are plotted. It should be noted that this method eliminates all the non-available data and plots the rest. It should be noted that the imported data belongs to the NTSB database which has a limited jurisdiction outside USA. So the data does not represent all the crash sites, however it represents the crash sites that was investigated by NTSB.

map<- get_map(location = geocode("INDIA"), zoom = 4,maptype = "roadmap", scale = 1)
ggmap(map) +geom_point(data = Accidents, aes(x = Longitude, y = Latitude, fill = "red",alpha = 0.5), size = 4, shape = 21,na.rm = F) +guides(fill=FALSE, alpha=FALSE, size=FALSE)

The above is a sample codes for plotting the data. The geocode can be resolved by providing a location string or passing the actual longitude and latitude. Similarly the zoom level can also be set. The maptype should be one of “terrain”, “satellite”, “roadmap”, “hybrid”.

Sample Plots

India

United States of America

Alaska

Anchorage

Africa

Europe

Australia