This function attempts to convert latitude and longitude coordinates to decimal degrees. It supports two formats: degrees minutes seconds (DMS) and degrees decimal minutes (DDS).
Usage
decimalDegrees(x, type = c("dms", "ddm"), isLongitude = FALSE)
Arguments
- x
A value or vector of latitude or longitude in dms or ddm format separated by a whitespace
- type
Either "dms" or "ddm". The lat/lon format of the input.
- isLongitude
T/F. Will expect the first set of number to have 3 digits. Will assign the value as negative and is specific only to the Bay-Delta area.
Examples
gpsDF <- data.frame(
Latitude = paste(c(rep(38, 7)), c(2, 3, 3, 4, 4, 3, 5), c(34.4, 37.1, 49, 35, 16, 39.9, 57.2)),
Longitude = paste(c(rep(122, 7)), c(2, 3, 3, 4, 4, 3, 5), c(34.4, 37.1, 49, 35, 16, 39.9, 57.2))
)
decimalDegrees(gpsDF$Latitude, type = "dms")
#> [1] 38.04289 38.06031 38.06361 38.07639 38.07111 38.06108 38.09922
decimalDegrees(gpsDF$Longitude, type = "ddm", isLongitude = TRUE)
#> [1] -122.0391 -122.0562 -122.0582 -122.0725 -122.0693 -122.0567 -122.0929