Convert latitudes and longitudes from degrees, minutes, and seconds to decimal degrees for conversion to spatial objects.
dms2dd(lon, lat)
a character vector of longitude coordinates in degrees, minutes,
and seconds; see details
a character vector of latitude coordinates in degrees, minutes,
and seconds; see details
An \(n * 2\) matrix where n is the length of lon
and lat
.
lon
and lat
are expected to be in the format
"degrees° minutes' seconds" (direction)"
where direction
is optional. If
direction
is not present, dms2dd
will use negative signs (-
) to
determine positioning of coordinates.
ll <- data.frame(lon = c("-122° 19' 55\"",
"71° 3' 32\" W"),
lat = c("47° 36' 22\"",
"42° 21' 36\" N"),
stringsAsFactors = FALSE)
dms2dd(ll[, 'lon'], ll[, 'lat'])
#> lon lat
#> 1 -121.66806 47.60611
#> 2 -71.05889 42.36000