deg2hms: Convert decimal degrees to hms format.

View source: R/deg2hms.R

deg2hmsR Documentation

Convert decimal degrees to hms format.

Description

Convert decimal degrees to hms (hours, minutes, seconds) format. This is probably most useful for right-ascension (RA) conversion, since hms is fairly standard method of presenting RA coordinates. The decimal degrees=15*h+15*m/60+15*s/3600 (i.e. there are 24 hours in 360 degrees). Degrees should range from 0 to 360.

Usage

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

Arguments

deg

The decimal degrees you are converting. All deg values should be 0<=d<=360.

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 'hms' or 'HMS' then the output is of the format 3h34m45.5s and 3H34M45.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

hms2deg

Examples

deg2hms(123.456)
deg2hms(123.456,type='cat',sep=':')
deg2hms(123.456,type='cat',sep='hms')
deg2hms(123.456,type='cat',sep='HMS')

asgr/celestial documentation built on Dec. 12, 2023, 10:06 a.m.