({{, (RefLink[DMSString, paclet:ref/DMSString])[θ]
converts an angle θ given in decimal degrees to a degrees-minutes-seconds string.}, {, (RefLink[DMSString, paclet:ref/DMSString])[{ϕ,λ}]
converts latitude and longitude given in decimal degrees to a DMS latitude-longitude string.}, {, (RefLink[DMSString, paclet:ref/DMSString])[{d,m,s}]
converts a DMS list to a DMS string.}})

OpenersNotesSection(Spacer1)Details

(RefLink[DMSString, paclet:ref/DMSString])[θ,"NS"] or (RefLink[DMSString, paclet:ref/DMSString])[θ,"EW"] gives a string representation in which the sign of the angle is indicated by one of the cardinal directions "N", "S", "E", or "W".

(RefLink[DMSString, paclet:ref/DMSString])[{ϕ,λ}] uses "N" for positive ϕ and "E" for positive λ.

(RefLink[DMSString, paclet:ref/DMSString])[θ,n] uses n-digit precision for seconds. (RefLink[DMSString, paclet:ref/DMSString])[θ,{"XY",n}] defines both sign representation and precision.

Angles in radians can be converted to degrees for use in (RefLink[DMSString, paclet:ref/DMSString]) by dividing by (RefLink[Degree, paclet:ref/Degree]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (12)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Convert an angle given in decimal degrees to a DMS string:

DMSString[20.53773]

Convert to a DMS string that specifies one of the cardinal directions:

DMSString[{-20,-3,-10},"NS"]

OpenersExampleSection1(Spacer1)Scope  (4)

Convert a DMS list into a DMS string:

DMSString[{27,12,3.45}]

For exact input, the result also contains exact numbers:

DMSString[{27,12,3}]

By default, (RefLink[DMSString, paclet:ref/DMSString]) ignores signs:

DMSString[{-27,-12,-3.45}]

DMSString[{27,12,3.45,"S"}]

They can be kept by using cardinal directions, either for latitude ("NS") or for longitude ("EW"):

DMSString[{-27,-12,-3.45},"NS"]

DMSString[{-27,-12,-3.45},"EW"]

DMSString[{27,12,3.45},"NS"]

DMSString[{27,12,3.45},"EW"]

DMSString[{27,12,3.45,"S"},"NS"]

DMSString[{27,12,3.45,"S"},"EW"]

Convert a numeric angle in degrees into a DMS string:

DMSString[123.34134]

A signed angle:

DMSString[-123.34134,"NS"]

By default, (RefLink[DMSString, paclet:ref/DMSString]) produces numbers with three decimals for seconds:

DMSString[189.34313]

The number of digits can be decreased or increased:

DMSString[189.34313,5]

DMSString[-189.34313,{"EW",0}]

DMSString[189.34313,{"NS",10}]

The precision parameter only affects the results of inexact inputs:

DMSString[189,10]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (3)

On DMS strings, (RefLink[DMSString, paclet:ref/DMSString]) returns a canonical form:

DMSString["23d11m49.92s North"]

The choice of cardinal direction is still free:

DMSString["23d11m49.92s South","EW"]

Act on a (RefLink[GeoPosition, paclet:ref/GeoPosition]) object, returning a pair "lat long":

$GeoLocation

%//DMSString

Convert a (RefLink[Quantity, paclet:ref/Quantity]) angle into a DMS string:

DMSString[Quantity[3.342387,"Radians"]]

DMSString[Quantity[-1.342387,"Radians"],"EW"]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

If the input contains any inexact number, the result will be inexact, always in the seconds:

DMSString[{20.,10,12}]

DMSString[{20,10.,12}]

Only when all numbers are exact will the result be exact:

DMSString[{20,10,12}]

DMSString[2017/100,"EW"]

The action of (RefLink[DMSString, paclet:ref/DMSString]) on a DMS list can be inverted with (RefLink[DMSList, paclet:ref/DMSList]):

DMSString[{34,23,14.78}]

DMSList[%]

With exact numbers:

DMSString[{34,23,15}]

DMSList[%]

The action of (RefLink[DMSString, paclet:ref/DMSString]) on a numeric angle in degrees can be inverted with (RefLink[FromDMS, paclet:ref/FromDMS]):

DMSString[34.3873]

FromDMS[%]

With exact numbers, (RefLink[DMSString, paclet:ref/DMSString]) returns a numerical approximation:

DMSString[343873/10000]

Hence the original exact number cannot be directly recovered:

FromDMS[%]

Rationalize[%]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DMSList, paclet:ref/DMSList])  ▪  (RefLink[FromDMS, paclet:ref/FromDMS])  ▪  (RefLink[LatitudeLongitude, paclet:ref/LatitudeLongitude])  ▪  (RefLink[Degree, paclet:ref/Degree])  ▪  (RefLink[GeodesyData, paclet:ref/GeodesyData])  ▪  (RefLink[GeoPosition, paclet:ref/GeoPosition])  ▪  (RefLink[GeoDistance, paclet:ref/GeoDistance])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Geodesy, paclet:guide/Geodesy])}, {▪(RefLinkPlain[Maps & Cartography, paclet:guide/MapsAndCartography])}, {▪(RefLinkPlain[Earth Sciences: Data & Computation, paclet:guide/EarthSciencesDataAndComputation])}, {▪(RefLinkPlain[Astronomical Computation & Data, paclet:guide/AstronomicalComputationAndData])}, {▪(RefLinkPlain[Angles and Polar Coordinates, paclet:guide/AnglesAndPolarCoordinates])}})}})