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.
char2dms(from, chd = "d", chm = "'", chs = "\"") dd2dms(dd, NS = FALSE)
- character vector of degree, minute, decimal second data
- degree character terminator
- minute character terminator
- second character terminator
- numeric vector of decimal degrees
- logical, TRUE for north/south decimal degrees, FALSE for east/west decimal degrees
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.
Both functions return a "DMS" object.
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))
Documentation reproduced from package sp, version 1.0-9. License: GPL (>= 2)