check_swept_area: Check Swept Area Calculation and Plot

View source: R/check_swept_area.r

check_swept_areaR Documentation

Check Swept Area Calculation and Plot

Description

Performs data validation and swept area calculation for MEDITS TA-format data. The function verifies numeric consistency in key columns, computes mean depth and swept area, logs any detected issues, and generates a plot of swept area versus mean depth for visual inspection.

Usage

check_swept_area(ResultDataTA, year, wd, suffix)

Arguments

ResultDataTA

A data.frame containing MEDITS hauls data in TA-format. The function uses the following columns: YEAR, VALIDITY, HAUL_NUMBER, WING_OPENING, DISTANCE, SHOOTING_DEPTH, HAULING_DEPTH, and TYPE_OF_FILE.

year

Numeric scalar. The year to be checked in the dataset.

wd

Character string. Path to the working directory where log files and plots will be saved.

suffix

Character string. Optional suffix to append to the output filenames. If NULL, a timestamp-based suffix is automatically generated.

Details

This function performs multiple validation steps on TA-format data for MEDITS hauls. It verifies that certain key columns contain numeric values and checks for missing or empty entries in critical fields such as WING_OPENING and DISTANCE.

For each haul, it calculates the mean depth as the average of SHOOTING_DEPTH and HAULING_DEPTH, and estimates the swept area in square kilometers using the formula (WING\_OPENING / 10) \times DISTANCE / 10^6. Any inconsistencies or errors encountered during these checks are written to a logfile stored in the Logfiles folder. If the data contains valid entries, the function generates and saves a scatter plot showing the swept area against mean depth. The plot includes a background shading to visually separate the depth range 0-200 meters from deeper strata, assisting in the interpretation of data distribution across depth zones. All output files are organized within subfolders named Logfiles and Graphs under the specified working directory.

Value

A logical value:

  • TRUE if no errors were detected in the data.

  • FALSE if at least one error was found and logged.

Author(s)

W. Zupa

Examples


# Define working directory
wd <- tempdir()

# Load data
ResultDataTA <- RoME::TA

# Filter for specific area if needed
ResultDataTA <- ResultDataTA[ResultDataTA$AREA == 18, ]

# Run the check for year 2005
check_swept_area(ResultDataTA, year = 2005, wd = wd, suffix = NULL)


RoME documentation built on April 24, 2026, 1:07 a.m.