deg2dms: Convert decimal degrees to dms format.

Description Usage Arguments Value Author(s) See Also Examples

Description

Convert decimal degrees to dms (degrees, minutes, seconds) format. This is probably most useful for declination conversion, since dms is fairly standard method of presenting declination coordinates. The decimal degrees=d+m/60+s/3600. Degrees should range from -90 to +90.

Usage

1
deg2dms(deg, type='mat', sep=':', digits=2)

Arguments

deg

The decimal degrees you are converting. All deg values should be -90<=deg<=90

type

The output type desired. If 'mat' then the output is a 3 column data.frame where column 1 is the degree, column 2 is the minutes and column 3 is the seconds. If 'cat' then the output is a single vector of strings where the separator is defined by the 'sep' argument.

sep

Defines the type of separator used when type='cat'. Any value other than 'DMS' and 'dms' is used for all separations, so the default ':' would produce an output like 3:34:45.5. If set to 'dms' or 'DMS' then the output is of the format 3d34m45.5s and 3D34M45.5s resepctively.

digits

The digits to print for angular seconds. See formatC for details on how digits is parsed.

Value

A data.frame with the columns degrees, minutes and seconds if type='mat'. If type='cat' then a vector of strings with separators defined by the 'sep' argument.

Author(s)

Aaron Robotham

See Also

dms2deg

Examples

1
2
3
4
print(deg2dms(12.345))
print(deg2dms(12.345,type='cat',sep=':'))
print(deg2dms(12.345,type='cat',sep='dms'))
print(deg2dms(12.345,type='cat',sep='DMS'))

Example output

Loading required package: RANN
Loading required package: NISTunits
Loading required package: pracma
     DEG   MIN  SEC    
[1,] "+12" "20" "42.00"
[1] "+12:20:42.00"
[1] "+12d20m42.00s"
[1] "+12D20M42.00S"

celestial documentation built on May 2, 2019, 3:05 p.m.