Learn R Programming

celestial (version 1.5.8)

deg2dms: Convert decimal degrees to dms format.

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

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

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.

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.

Author

Aaron Robotham

See Also

dms2deg

Examples

Run this code
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'))

Run the code above in your browser using DataLab