Learn R Programming

RWmisc (version 0.1.2)

dms2dd: Convert from degrees, minutes, and seconds to decimal degrees

Description

Convert latitudes and longitudes from degrees, minutes, and seconds to decimal degrees for conversion to spatial objects.

Usage

dms2dd(lon, lat)

Arguments

lon

a character vector of longitude coordinates in degrees, minutes, and seconds; see details

lat

a character vector of latitude coordinates in degrees, minutes, and seconds; see details

Value

An \(n * 2\) matrix where n is the length of lon and lat.

Details

lon and lat are expected to be in the format "degrees<U+00B0> minutes' seconds" (direction)" where direction is optional. If direction is not present, dms2dd will use negative signs (-) to determine positioning of coordinates.

Examples

Run this code
# NOT RUN {
ll <- data.frame(lon = c("-122<U+00B0> 19' 55\"",
                         "71<U+00B0> 3' 32\" W"),
                 lat = c("47<U+00B0> 36' 22\"",
                         "42<U+00B0> 21' 36\" N"),
                 stringsAsFactors = FALSE)
dms2dd(ll[, 'lon'], ll[, 'lat'])
# }

Run the code above in your browser using DataLab