BenioffOceanInitiative / whalesafe

Ships for Whales scripts and project management
https://BenioffOceanInitiative.github.io/whalesafe
MIT License
1 stars 1 forks source link

fix ais data with mmsi as ship name, not integer #9

Open bbest opened 4 years ago

bbest commented 4 years ago

@bbest noticed that 6 mmsi codes showed up as ship names, not integers

bbest commented 4 years ago

per:

https://github.com/BenioffOceanInitiative/s4w-apps/blob/0b871f1d40bd4643635762ef3bff688ff1af0bfa/tbl/global.R#L21-L46

  ships <- tbl(con, "ais_data") %>% 
    group_by(mmsi, name, ship_type) %>% 
    summarise(
      nrows_ais   = n(),
      speed_min   = min(speed, na.rm=T),
      speed_max   = max(speed, na.rm=T),
      heading_min = min(heading, na.rm=T),
      heading_max = max(heading, na.rm=T),
      date_beg    = min(datetime, na.rm=T),
      date_end    = max(datetime, na.rm=T),
      lon_min     = min(lon, na.rm=T),
      lon_max     = max(lon, na.rm=T),
      lat_min     = min(lat, na.rm=T),
      lat_max     = max(lat, na.rm=T)) %>% 
    collect()

  write_csv(ships, ships_csv)
}
ships <- read_csv(ships_csv, n_max = 10386)
# Warning: 6 parsing failures.
# row  col expected          actual                                file
# 10387 mmsi a double A.N. TILLETT    '/srv/shiny-server/cache/ships.csv'
# 10388 mmsi a double US GOV VESSEL   '/srv/shiny-server/cache/ships.csv'
# 10389 mmsi a double US NAVY SHIP 92 '/srv/shiny-server/cache/ships.csv'
# 10390 mmsi a double US WARSHIP      '/srv/shiny-server/cache/ships.csv'
# 10391 mmsi a double US WARSHIP 92   '/srv/shiny-server/cache/ships.csv'