R/lon_checker.R

#' Convert Longitudes into -180 to 180 
#'
#' Takes in a set of longitude coordinate values, checks if they sit in the range [-180, 180] or [0, 360]. If the latter is true, then the coordinate values are coverted into the former.
#' @param lon_coords
longitude_checker <- function(lon_coords){
  maxi <- max(lon_coords)
  mini <- min(lon_coords)
  if (maxi>180){
    print('Converting Coordinate Values.')
    coords <- lon_coords - 180
  } else {
    print('No Conversion Required.')
    coords <- lon_coords
  }
  return(coords)
}
thomaspinder/usefulRFunctions documentation built on May 10, 2019, 8:27 a.m.