This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converting coordinates from DMS or DdM formats to decimal | |
# DMS = "degrees minutes seconds"; DdM = "degrees decimal minutes" | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
dg2dec <- function(varb, Dg=NA, Min=NA, Sec=NA, SW.Hemisphere="S|W") { | |
# Dg=decimal, Min=minutes and Sec=seconds; | |
# NOTE 1 - if the format is "degrees decimal minutes - DdM" (e.g. 40° 26.767′ N) and not | |
# "degrees minutes seconds - DMS" (e.g. 40° 26′ 46″ N), then call the function only with | |
# Dg and Min arguments, like dg2dec(varb, Dg="°", Min="′N"). | |
# Same applies when there is no seconds symbol (e.g. 45°12'7.38). | |
# Note that one should not use blank spaces in Dg, Min or Sec arguments (will return NA). |