Chapter 4 Filter & combine surveys

You may soon encounter the need to filter a processed cruz object to only certain years, regions, or cruise numbers. You may also need to combine one processed cruz object with another. The function below assist with these tasks.

Here we will continue with the cruz object we created on the previous page. As a reminder, here is the data structure of that object:

cruz_structure(cruz)
"cruz" list structure ========================

$settings
         $strata --- with 12 polygon coordinate sets
         $survey --- with 15 input arguments
         $cohorts --- with 3 cohorts specified, each with 19 input arguments

$strata
       ... containing a summary dataframe of 12 geostrata and their spatial areas
       ... geostratum names:
           HI_EEZ, OtherCNP, MHI, WHICEAS, Spotted_OU, Spotted_FI, Spotted_BI, Bottlenose_KaNi, Bottlenose_OUFI, Bottlenose_BI, nwhi_fkw, mhi_fkw

$cohorts

        $all
            geostrata: WHICEAS, HI_EEZ, OtherCNP
            $segments  --- with 1454 segments (median = 149.5 km)
            $das       --- with 329638 data rows
            $sightings --- with 3934 detections
            $subgroups --- with 255 subgroups, 61 sightings, and 389 events

        $bottlenose
            geostrata: WHICEAS, HI_EEZ, OtherCNP, Bottlenose_BI, Bottlenose_OUFI, Bottlenose_KaNi
            $segments  --- with 1538 segments (median = 149.3 km)
            $das       --- with 329638 data rows
            $sightings --- with 523 detections

        $spotted
            geostrata: WHICEAS, HI_EEZ, OtherCNP, Spotted_OU, Spotted_FI, Spotted_BI
            $segments  --- with 1538 segments (median = 149.2 km)
            $das       --- with 329638 data rows
            $sightings --- with 527 detections

Filter

LTabundR lets you filter a cruz object using the function filter_cruz().

For example, in our WHICEAS case study, we processed surveys from 1986 - 2020, which we needed to do to model our detection functions, but our interest for mapping is specifically valid effort in 2017 and 2020 only, and only within the "WHICEAS" geostratum.

cruz_1720 <- 
  filter_cruz(cruz,
              analysis_only = TRUE,
              years = c(2017, 2020),
              regions = 'WHICEAS')

We will use this filtered cruz object for mapping & sightings summaries downstream.

save(cruz_1720,file='whiceas_cruz_1720.RData')

Note that filter_cruz() has many other filter options. See ?filter_cruz() for details.

Combine

Say you have two processed cruz objects: one containing survey effort from the Hawaiian EEZ (HI_EEZ) geostratum area only, and one containing survey effort from everywhere else that does not include HI_EEZ effort.

Let’s make those fake datasets right now, using filter_cruz():

Hawaiian EEZ-only data:

cruz_hi <- filter_cruz(cruz, 
                            regions = 'HI_EEZ', 
                            verbose = FALSE)

Outside Hawaiian EEZ-only data:

cruz_other <- filter_cruz(cruz, 
                           not_regions = 'HI_EEZ', 
                           verbose = FALSE)

Say you want to combine these datasets together in order to reconstruct the equivalent of our original cruz object. You can do this with the LTabundR function, cruz_combine().

# Make a list of cruz objects
cruzes <- list(cruz_hi, cruz_other)

# Now combine
cruz_demo <- cruz_combine(cruzes)

Re-constituted data structure:

cruz_structure(cruz_demo)
"cruz" list structure ========================

$settings
         $strata --- with 12 polygon coordinate sets
         $survey --- with 15 input arguments
         $cohorts --- with 3 cohorts specified, each with 19 input arguments

$strata
       ... containing a summary dataframe of 12 geostrata and their spatial areas
       ... geostratum names:
           HI_EEZ, OtherCNP, MHI, WHICEAS, Spotted_OU, Spotted_FI, Spotted_BI, Bottlenose_KaNi, Bottlenose_OUFI, Bottlenose_BI, nwhi_fkw, mhi_fkw

$cohorts

        $all
            geostrata: WHICEAS, HI_EEZ, OtherCNP
            $segments  --- with 1454 segments (median = 149.5 km)
            $das       --- with 329638 data rows
            $sightings --- with 3934 detections
            $subgroups --- with 255 subgroups, 61 sightings, and 389 events

        $bottlenose
            geostrata: WHICEAS, HI_EEZ, OtherCNP, Bottlenose_BI, Bottlenose_OUFI, Bottlenose_KaNi
            $segments  --- with 1538 segments (median = 149.3 km)
            $das       --- with 329638 data rows
            $sightings --- with 523 detections

        $spotted
            geostrata: WHICEAS, HI_EEZ, OtherCNP, Spotted_OU, Spotted_FI, Spotted_BI
            $segments  --- with 1538 segments (median = 149.2 km)
            $das       --- with 329638 data rows
            $sightings --- with 527 detections