Learn R Programming

SHARK4R (version 1.0.2)

convert_ddmm_to_dd: Convert coordinates from DDMM format to decimal degrees

Description

This function converts geographic coordinates provided in the DDMM format (degrees and minutes) to decimal degrees. It can handle:

  • DDMM (e.g., 5733 to 57°33' to 57.55°)

  • DDMMss or DDMMss… (extra digits after minutes are interpreted as fractional minutes, e.g., 573345 to 57°33.45' to 57.5575°)

Usage

convert_ddmm_to_dd(coord)

Value

A numeric vector of decimal degrees corresponding to the input coordinates. Names from the input vector are removed.

Arguments

coord

A numeric or character vector of coordinates in DDMM format.

Details

Non-numeric characters are removed before conversion. Coordinates shorter than 4 digits are returned as NA.

Examples

Run this code
# Basic DDMM input
convert_ddmm_to_dd(c(5733, 6045))
# Input with fractional minutes
convert_ddmm_to_dd(c("573345", "604523"))
# Input with non-numeric characters
convert_ddmm_to_dd(c("57°33'", "60°45'23\""))

Run the code above in your browser using DataLab