Package 'crputils'

Title: Miscellaneous R Utilities Useful to CRP
Description: A collection of miscellaneous utilities that are useful for various research activities conducted by the Cetacean Research Program (CRP) at NOAA NMFS Pacific Islands Fisheries Science Center. This includes utilities for working with latitude and longitude data, gpx file creation, and more to come.
Authors: Selene Fregosi [aut, cre]
Maintainer: Selene Fregosi <[email protected]>
License: GPL (>= 3)
Version: 0.1.9003
Built: 2025-01-12 05:21:27 UTC
Source: https://github.com/PIFSC-Protected-Species-Division/crputils

Help Index


CSVToGPX_track

Description

convert a .csv of vessel track segments to a .gpx file.

The input data.frame must have 1 column 'uid' containing a unique identifier for that track/segment, 2 columns for start latitude and longitude, and 2 columns for stop latitude and longitude. Additional columns for cruise, date, vessel name, etc will be ignored

This is a modified version of trackToGPX.R that is included in the 'cruise-maps-live' repository that tries to generalize the function to convert any input data.frame, not just the output from a .das file.

Usage

CSVToGPX_track(inCSV, outGPX)

Arguments

inCSV

filename of csv containing track data to be processed. Must include the following columns: uid, startLat, startLon, stopLat, stopLon where uid is a unique track identifier, startLat/startLon is the track start location and stopLat/stopLon is the track end location. All locations should be in decimal degrees. Can optionally include a startDateTime and stopDateTime column. Assumes UTC timezone for GPX output.

outGPX

fullpath filename of gpx to be written example: outGPX <- './crputils/exampleData/exampleVesselTrack.gpx'

Value

none, will write a file

Author(s)

Selene Fregosi


DASTrackToGPX

Description

create a .gpx file based on the effort track data recorded in .DAS files. The track data needs to have been extracted from the .DAS file using extractDASTrack() which creates the 'et' dataframe

Track segments within days are plotted separately but are connected. Tracks across days are not connected.

This was generalized from the cruise-maps-live repository's trackToGPX()

Usage

DASTrackToGPX(et, outGPX)

Arguments

et

data.frame of effort as tracks, can be 'et' cumulative over a survey or 'et' for just a single DAS

outGPX

fullpath filename to save example: outGPX <- paste0('newEffortTracks_', dasName, '_', Sys.Date(), '.gpx')

Value

none, will write a file

Author(s)

Selene Fregosi


decdeg2degmin

Description

Utility to convert latitude and longitude coordinates from decimal degrees to degrees decimal minutes

Usage

decdeg2degmin(decdeg)

Arguments

decdeg

N-by-1 vector of coordinates in decimal degrees e.g., decdeg <- 30.48667 OR decdeg <- c(30.48667, -155.61496)

Value

N-by-2 data.frame of coordinates with columns 'deg' for degrees and 'min' for decimal minutes

Author(s)

Selene Fregosi

Examples

# single input coordinates
decdeg <- 30.48667
degmin <- decdeg2degmin(decdeg)

# multiple input coordinates
decdeg <- c(30.48667, -155.61496)
degmin <- decdeg2degmin(decdeg)

decdeg2degminsec

Description

Utility to convert latitude and longitude coordinates from degrees minutes to degrees minutes second

Usage

decdeg2degminsec(decdeg)

Arguments

decdeg

N-by-1 vector of coordinates in decimal degrees e.g., decdeg <- 30.48667 OR decdeg <- c(30.48667, -155.61496)

Value

N-by-3 data.frame of coordinates with columns 'deg' for degrees, 'min' for minutes, and 'sec' for decimal seconds

Author(s)

Selene Fregosi

Examples

# single input coordinates
decdeg <- 30.48667
degminsec <- decdeg2degminsec(decdeg)

# multiple input coordinates
decdeg <- c(30.48667, -155.61496)
degminsec <- decdeg2degminsec(decdeg)

Degrees decimal minutes to decimal degrees

Description

Utility to convert latitude and longitude coordinates from degrees minutes to decimal degrees

Usage

degmin2decdeg(degmin)

Arguments

degmin

N-by-2 matrix of coordinates with each column representing degrees and minutes. e.g., matrix(c(30, 29.2020), nrow = 1, ncol = 2) e.g., matrix(c(30, 29.2020, -155, 36.8973), nrow = 2, ncol = 2, byrow = TRUE)

Value

N-by-1 vector of coordinates in decimal degrees

Author(s)

Selene Fregosi

Examples

# single input coordinates
degmin <- matrix(c(30, 29.2020), nrow = 1, ncol = 2)
decdeg <- degmin2decdeg(degmin)

# multiple input coordinates
degmin <- matrix(c(30, 29.2020,
                     -155, 36.8973),
                   nrow = 2, ncol = 2, byrow = TRUE)
decdeg <- degmin2decdeg(degmin)

degmin2degminsec

Description

Utility to convert latitude and longitude coordinates from degrees minutes to degrees minutes seconds

Usage

degmin2degminsec(degmin)

Arguments

degmin

N-by-2 matrix of coordinates with each column representing degrees and minutes e.g., matrix(c(30, 29.2020), nrow = 1, ncol = 2) e.g., matrix(c(30, 29.2020, -155, 36.8973), nrow = 2, ncol = 2, byrow = TRUE)

Value

N-by-3 data.frame of coordinates with columns 'deg for degrees and 'min' for minutes and 'sec' for decimal seconds

Author(s)

Selene Fregosi

Examples

# single input coordinates
degmin <- matrix(c(30, 29.2020), nrow = 1, ncol = 2)
degminsec <- degmin2degminsec(degmin)

# multiple input coordinates
degmin <- matrix(c(30, 29.2020,
                     -155, 36.8973),
                   nrow = 2, ncol = 2, byrow = TRUE)
degminsec <- degmin2degminsec(degmin)

degminsec2decdeg

Description

Utility to convert latitude and longitude coordinates from degrees minutes seconds to decimal degrees

Usage

degminsec2decdeg(degminsec)

Arguments

degminsec

N-by-3 matrix of coordinates with each column representing degrees, minutes, and seconds e.g., matrix(c(30, 29, 12), nrow = 1, ncol = 3) e.g., matrix(c(30, 29, 12, -155, 36, 53.838), nrow = 2, ncol = 3, byrow = TRUE)

Value

N-by-1 vector of coordinates in decimal degrees

Author(s)

Selene Fregosi

Examples

# single input coordinates
degminsec = matrix(c(30, 29, 12), nrow = 1, ncol = 3)
decdeg = degminsec2decdeg(degminsec)

# multiple input coordinates
degminsec = matrix(c(30, 29, 12,
                     -155, 36, 53.838),
                   nrow = 2, ncol = 3, byrow = TRUE)
decdeg = degminsec2decdeg(degminsec)

degminsec2degmin

Description

Utility to convert latitude and longitude coordinates from degrees minutes seconds to degrees decimal minutes

Usage

degminsec2degmin(degminsec)

Arguments

degminsec

N-by-3 matrix of coordinates with each column representing degrees, minutes, and seconds e.g., matrix(c(30, 29, 12), nrow = 1, ncol = 3) e.g., matrix(c(30, 29, 12, -155, 36, 53.838), nrow = 2, ncol = 3, byrow = TRUE)

Value

N-by-2 data.frame of coordinates with columns 'deg' for degrees and 'min' for minutes

Author(s)

Selene Fregosi

Examples

# single input coordinates
degminsec <- matrix(c(30, 29, 12), nrow = 1, ncol = 3)
degmin <- degminsec2degmin(degminsec)

# multiple input coordinates
degminsec <- matrix(c(30, 29, 12,
                     -155, 36, 53.838),
                   nrow = 2, ncol = 3, byrow = TRUE)
degmin <- degminsec2degmin(degminsec)

extractDASTrack

Description

Pull effort tracks from a relatively raw daily .das file into a simpler dataframe. Utilizes the package swfscDAS and then cleans up those outputs a bit. Generalized from cruise-maps-live's extractTrack()

Usage

extractDASTrack(df_proc)

Arguments

df_proc

processed das file (with swfscDAS::das_process)

Value

a dataframe of effort tracks with date and lat/lon

Author(s)

Selene Fregosi