R/pretty_coordinates.R

Defines functions degrees pretty_coordinates

Documented in degrees pretty_coordinates

#' Pretty coordinates
#'
#' Creates pretty coordinates for printing.
#'
#' @export
#'
#' @param x A vector contain data of the format degree-minutes-second (ddmmss)
#' @param suffix A character, e.g. N, E, W, S
pretty_coordinates <- function(x,suffix="") {
  x <- paste0(degrees(stringr::str_sub(x,1,2)),stringr::str_sub(x,3,4),"'",stringr::str_sub(x,5,6),suffix,sep="")
  return(x)
}

#' degrees
#'
#' Af function that adds the suffix degree to object. Used e.g.
#' in \code{pretty_coordinates}
#'
#' @param x A value or text
degrees <- function(x) paste0(x,"\u00B0")
einarhjorleifsson/gisland documentation built on Feb. 2, 2024, 11:21 p.m.