# Degree Decimal (DD) to Degree Minutes Seconds (DMS)
dec2dms = function(coord, num = TRUE)
{
out = sapply(coord,
function(coord, num)
{
## standardized in vector numerical
crd = coord_clean(coord)
if(length(crd) > 1) if(num) return(crd) else return(coord)
if(crd %% 1 == 0)
{
if(num) {
out = c("deg" = crd, "min" = 0, "sec" = 0)
return(out)
} else {
out = paste0(crd, "\uB0 ", 0, "\u27 ", 0, "\u22")
return(out)
}#end if
}#end if
signal = sign(crd)
crd = abs(crd)
degree = crd - crd %% 1
m1 = (crd %% 1) * 60
minutes = m1 - (m1 %% 1)
seconds = (m1 %% 1) * 60
if(num) out = c("deg" = signal * degree, "min" = minutes, "sec" = round(seconds, 3))
else out = paste0(signal * degree, "\uB0 ", minutes, "\u27 ", round(seconds, 3), "\u22")
return(out)
},#end function
num = num )#end sapply
if(num)
{
out = t(out)
rn = 1:nrow(out)
out = as.data.frame(out, row.names = rn)
out$Coord = coord
}#end if
return(out)
}#end dec2dms
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.