gmt (version 1.2-0)

num2deg: Convert Numeric to Degrees

Description

Convert decimal number to deg:min:sec string.

Usage

num2deg(x, lat=NA, dec=FALSE, digits=0, zero=FALSE)

Arguments

x
number or vector of numbers.
lat
whether x is latitude.
dec
whether to return decimal degrees instead of deg:min:sec.
digits
precision used when rounding decimal degrees or seconds.
zero
whether trailing :00 zeros should be retained.

Value

Details

Element-specific format is supported, using vectors for lat, digits, and precision.

The resulting string ends with N or S when lat is TRUE, E or W when lat is FALSE, or a number when lat is NA.

See Also

as.character converts plain numbers to strings.

num2deg is the opposite of deg2num.

gmt-package gives an overview of the package.

Examples

Run this code
# The opposite of deg2num() example
num2deg(c(-12.51236, -17.5, 1.00139, 200.75),
        lat=c(FALSE, TRUE,  NA,      FALSE),
        dec=c(FALSE, TRUE,  FALSE,   FALSE),
        digits=c(1,  1,     0,       0))

Run the code above in your browser using DataLab