Learn R Programming

enmSdmX (version 1.2.12)

dmsToDecimal: Convert geographic coordinates in degrees-minutes-second to decimal format

Description

This function converts geographic coordinates in degrees-minutes-seconds (DD-MM-SS) format to decimal format.

Usage

dmsToDecimal(dd, mm, ss, hemis = NULL)

Value

Numeric.

Arguments

dd

Numeric. Degrees longitude or latitude. Can be a decimal value.

mm

Numeric. Minutes longitude or latitude. Can be a decimal value.

ss

Numeric. Second longitude or latitude. Can be a decimal value.

hemis

Character or NULL (default). "N" (north), "S" (south), "E" (east), or "W" (west). If left as NULL, then the value returned will always be positive, even if it is in the western or southern hemisphere.

Examples

Run this code
dmsToDecimal(38, 37, 38) # latitude of St. Louis, Missouri, USA
dmsToDecimal(38, 37, 38, 'N') # latitude of St. Louis, Missouri, USA
dmsToDecimal(90, 11, 52.1) # longitude of St. Louis, Missouri, USA
dmsToDecimal(90, 11, 52.1, 'W') # longitude of St. Louis, Missouri, USA

Run the code above in your browser using DataLab