Learn R Programming

Tivy (version 0.1.1)

dms_to_decimal: Convert latitude or longitude to decimal degrees

Description

Converts coordinates expressed in degrees, minutes and seconds (DMS) or degrees and minutes (DM) format to decimal degrees. By default, coordinates are assumed to be in the southern hemisphere (negative latitudes). The function can automatically correct common errors such as minutes or seconds greater than 60.

Usage

dms_to_decimal(coordinates, hemisphere = "S", correct_errors = TRUE)

Value

Numeric vector with coordinates converted to decimal degrees.

Arguments

coordinates

Character vector. Each element should be in formats such as: "D M S", "D M", "17 26 S"

hemisphere

Character indicating hemisphere when not specified in the coordinate. One of "N", "S", "E", "W" or "O". "S" and "W"/"O" generate negative values.

correct_errors

Logical. If TRUE, automatically corrects out-of-range values.

Examples

Run this code
dms_to_decimal(c("73 15 0"), hemisphere = "W")

Run the code above in your browser using DataLab