FCE_Acoustic Data Submission_EDI

Author

Mack White

Generation of Acoustic Data Submission for FCE

Setup

library(readr)
library(tidyverse)
library(leaflet)
library(DT)

Read in CSV Output from Last Round of Data Submission

Ensure we are formatting new data correctly

prior_submission <- read_csv("../csv outputs/LT_TDCS_Rehage_004_2021.csv")
glimpse(prior_submission)
Rows: 5,167,429
Columns: 5
$ Transmitter  <chr> "A69-1303-32892", "A69-1303-32892", "A69-1303-32892", "A6…
$ Species      <chr> "Common Snook (Centropomus undecimalis)", "Common Snook (…
$ Datetime_UTC <dttm> 2015-02-09 20:24:21, 2014-12-01 06:05:12, 2014-06-18 20:…
$ Latitude     <dbl> 25.45688, 25.42807, 25.45688, 25.45688, 25.45427, 25.4542…
$ Longitude    <dbl> -80.87605, -80.91492, -80.87605, -80.87605, -80.88065, -8…

Ultimately Need Five Columns in Data Submission

Transmitter (chr)

Species (chr)

Datetime_UTC (dttm)

Latitude (dbl)

Longitude (dbl)

Read in Snook, Bass, and Redfish Data

These are POR (e.g., AllSnook_PeriodOfRecord_06142023.rds) “data from most recent download event

Snook <- read_rds("../data/AllSnook_PeriodOfRecord_06142023.rds")
Bass <- read_rds("../data/AllBass_PeriodOfRecord_06142023.rds")
Redfish <- read_rds("../data/AllRedfish_PeriodOfRecord_06142023.rds")

Add Species Name Column & Remove Unnecessary Columns for Each Species

Need species id prior to join to differentiate

Snook <- Snook |> 
      select(Transmitter, Datetime_UTC, Latitude, Longitude) |> 
      mutate(Species = "Common Snook (Centropomus undecimalis)")

Bass <- Bass |> 
      select(Transmitter, Datetime_UTC, Latitude, Longitude) |> 
      mutate(Species = "Largemouth Bass (Micropterus salmoides)")

Redfish <- Redfish |> 
      select(Transmitter, Datetime_UTC, Latitude, Longitude) |> 
      mutate(Species = "Red Drum (Sciaenops ocellatus)")

Join Cleaned Data Frames

SnookBass <- full_join(Snook, Bass)

SnookBassRedfish <- full_join(SnookBass, Redfish)

Ensure Columns are Classified (e.g., dttm) correctly

Fix if not

glimpse(SnookBassRedfish)
Rows: 7,154,425
Columns: 5
$ Transmitter  <fct> A69-1303-51309, A69-1303-58417, A69-1303-51325, A69-1303-…
$ Datetime_UTC <dttm> 2012-04-17 19:22:14, 2012-05-16 23:46:42, 2012-05-02 16:…
$ Latitude     <dbl> 25.44403, 25.44403, 25.44403, 25.44403, 25.44403, 25.4440…
$ Longitude    <dbl> -80.96093, -80.96093, -80.96093, -80.96093, -80.96093, -8…
$ Species      <chr> "Common Snook (Centropomus undecimalis)", "Common Snook (…
ForSubmission <- SnookBassRedfish |> 
      mutate(Transmitter = as.character(Transmitter)) |> 
      relocate(Species, .after = Transmitter)
      

glimpse(ForSubmission)
Rows: 7,154,425
Columns: 5
$ Transmitter  <chr> "A69-1303-51309", "A69-1303-58417", "A69-1303-51325", "A6…
$ Species      <chr> "Common Snook (Centropomus undecimalis)", "Common Snook (…
$ Datetime_UTC <dttm> 2012-04-17 19:22:14, 2012-05-16 23:46:42, 2012-05-02 16:…
$ Latitude     <dbl> 25.44403, 25.44403, 25.44403, 25.44403, 25.44403, 25.4440…
$ Longitude    <dbl> -80.96093, -80.96093, -80.96093, -80.96093, -80.96093, -8…

If looks correct, write as csv and submit

write_csv(ForSubmission, "../csv outputs/LT_TDCS_Rehage_004_2023.csv")

check <- read_csv("../csv outputs/LT_TDCS_Rehage_004_2023.csv")
glimpse(check)
Rows: 7,154,425
Columns: 5
$ Transmitter  <chr> "A69-1303-51309", "A69-1303-58417", "A69-1303-51325", "A6…
$ Species      <chr> "Common Snook (Centropomus undecimalis)", "Common Snook (…
$ Datetime_UTC <dttm> 2012-04-17 19:22:14, 2012-05-16 23:46:42, 2012-05-02 16:…
$ Latitude     <dbl> 25.44403, 25.44403, 25.44403, 25.44403, 25.44403, 25.4440…
$ Longitude    <dbl> -80.96093, -80.96093, -80.96093, -80.96093, -80.96093, -8…
range(check$Datetime_UTC)
[1] "2009-11-25 01:02:49 UTC" "2023-04-15 20:59:46 UTC"

For fun, make a map

Below, summarize data to make easier to work with for map and summary table

all_summary <- ForSubmission |> 
      group_by(Latitude,Longitude,Species) |> 
      summarize(observations = n())
`summarise()` has grouped output by 'Latitude', 'Longitude'. You can override
using the `.groups` argument.
station_info <- read_csv("../data/Station_Distance_Updated07142020.csv")
Rows: 83 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): Station, VUE_Name
dbl (3): Distance, Latitude, Longitude

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
summary_full <- right_join(all_summary, station_info) |> 
      drop_na()
Joining with `by = join_by(Latitude, Longitude)`

Map of all sites with their names generated below

leaflet(summary_full) %>%
    addWMSTiles(
        "https://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WmsServer",
        layers = "0",
        options = WMSTileOptions(format = "image/png", transparent = TRUE)) %>%
    addWMSTiles(
        "https://basemap.nationalmap.gov/arcgis/services/USGSHydroCached/MapServer/WmsServer",
        layers = "0",
        options = WMSTileOptions(format = "image/png", transparent = TRUE)) %>%
    addCircleMarkers(
        lng = ~ Longitude,
        lat = ~ Latitude,
        popup = ~ VUE_Name,
        radius = 5,
        # set fill properties
        fillColor = "salmon",
        fillOpacity = 1,
        # set stroke properties
        stroke = T,
        weight = 0.5,
        color = "white",
        opacity = 1)