\HeaderA{char2dms}{Convert character vector to DMS-class object}{char2dms}
\aliasA{as.character.DMS}{char2dms}{as.character.DMS}
\aliasA{coerce,DMS,character-method}{char2dms}{coerce,DMS,character.Rdash.method}
\aliasA{coerce,DMS,numeric-method}{char2dms}{coerce,DMS,numeric.Rdash.method}
\aliasA{dd2dms}{char2dms}{dd2dms}
\keyword{spatial}{char2dms}
\begin{Description}\relax
These two helper functions convert character vectors and decimal degree vectors to the DMS-class representation of degrees, minutes, and decimal seconds. "DMS" objects cannot contain NAs.
\end{Description}
\begin{Usage}
\begin{verbatim}
char2dms(from, chd = "d", chm = "'", chs = "\"")
dd2dms(dd, NS = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{from}] character vector of degree, minute, decimal second data
\item[\code{chd}] degree character terminator
\item[\code{chm}] minute character terminator
\item[\code{chs}] second character terminator
\item[\code{dd}] numeric vector of decimal degrees
\item[\code{NS}] logical, TRUE for north/south decimal degrees, FALSE for east/west decimal degrees
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
In char2dms, the input data vector should use a regular format, such as that used in the PROJ.4 library, with a trailing capital (NSWE) indicating compass direction.
\end{Details}
\begin{Value}
Both functions return a "DMS" object.
\end{Value}
\begin{Section}{Methods}
\describe{

\item[from = "DMS", to = "numeric"] coerce a \code{"DMS"} object to a \code{"numeric"} vector

\item[from = "DMS", to = "character"] coerce a \code{"DMS"} object to a \code{"character"} vector (the \code{as.character.DMS} S3 function is also available)
}
\end{Section}
\begin{Author}\relax
Roger Bivand \email{Roger.Bivand@nhh.no}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{DMS-class}{DMS.Rdash.class}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(state)
str(state.center$y)
stateN <- dd2dms(state.center$y, NS=TRUE)
str(attributes(stateN))
ch.stateN <- as.character(stateN)
str(ch.stateN)
stateNa <- char2dms(ch.stateN)
str(attributes(stateNa))
ch.stateN <- as(stateN, "character")
str(ch.stateN)
stateNa <- char2dms(ch.stateN)
str(attributes(stateNa))
\end{ExampleCode}
\end{Examples}

