Debian Codegraph @

man/char2dms.Rd

raw
1 \name{char2dms}
2 \alias{char2dms}
3 \alias{dd2dms}
4 \alias{coerce,DMS,numeric-method}
5 \alias{coerce,DMS,character-method}
6 \alias{as.character.DMS}
7 %- Also NEED an '\alias' for EACH other topic documented here.
8 \title{Convert character vector to DMS-class object}
9 \description{
10 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.
11 }
12
13 \section{Methods}{\describe{
14
15 \item{from = "DMS", to = "numeric"}{coerce a \code{"DMS"} object to a \code{"numeric"} vector}
16
17 \item{from = "DMS", to = "character"}{coerce a \code{"DMS"} object to a \code{"character"} vector (the \code{as.character.DMS} S3 method is also available)}
18 }}
19 \usage{
20 char2dms(from, chd = "d", chm = "'", chs = "\"")
21 dd2dms(dd, NS = FALSE)
22 }
23 %- maybe also 'usage' for other objects documented here.
24 \arguments{
25 \item{from}{character vector of degree, minute, decimal second data}
26 \item{chd}{degree character terminator}
27 \item{chm}{minute character terminator}
28 \item{chs}{second character terminator}
29 \item{dd}{numeric vector of decimal degrees}
30 \item{NS}{logical, TRUE for north/south decimal degrees, FALSE for east/west decimal degrees}
31 }
32 \details{
33 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.
34 }
35 \value{
36 Both functions return a "DMS" object.
37 }
38
39 \author{Roger Bivand \email{[email protected]} }
40
41 \seealso{\code{\link{DMS-class}}}
42 \examples{
43 data(state)
44 str(state.center$y)
45 stateN <- dd2dms(state.center$y, NS=TRUE)
46 str(attributes(stateN))
47 ch.stateN <- as.character(stateN)
48 str(ch.stateN)
49 stateNa <- char2dms(ch.stateN)
50 str(attributes(stateNa))
51 ch.stateN <- as(stateN, "character")
52 str(ch.stateN)
53 stateNa <- char2dms(ch.stateN)
54 str(attributes(stateNa))
55 }
56 \keyword{spatial}