R/latLong2UTM.R

Defines functions latLong2UTM

Documented in latLong2UTM

#' Get valid UTM zone from latitude and longitude in WGS84 decimal degrees
#'
#' @param x vector of longitude coordinates in decimal degrees
#' @param y vector of latitude coordinate in decimal degrees
#'
#' @return Vector of UTM zones for each latitude-longitude pair
#' 
#' @export
#' 
latLong2UTM <- function(x, y) {
  unlist(lapply(1:length(x), function(z) {
    paste((floor((x[z] + 180) / 6) %% 60) + 1,
      ifelse(y[z] < 0, "S", "N"),
      sep = "")
  }))
}
johngodlee/JLGMisc documentation built on July 17, 2025, 3:09 a.m.