Skip to contents

Convert a data frame column with degrees, minutes as well as seconds to decimal degrees.

Usage

dms_column_to_decimal(df, coord_col)

Arguments

df

Data frame containing the DMS columns.

coord_col

Name of the column with coordinates in degrees.

Value

Data frame with a new column containing decimal degrees.

Author

Sander Devisscher

Examples

if (FALSE) { # \dontrun{
# Example data frame
df <- data.frame(
 lat_Y = c("50\u00B045'38.7\"N", "50\u00B046'04.9\"N", "50\u00B045'19.7\"N",
 "50\u00B045'18.0\"N", "50\u00B046'24.4\"N", "50\u00B045'29.2\"N"),
 long_X = c("3\u00B010'26.0\"E", "3\u00B010'28.0\"E", "3\u00B010'25.0\"E",
 "3\u00B010'24.0\"E", "3\u00B010'30.0\"E", "3\u00B010'27.0\"E"))

# Convert the lat_Y and long_X columns to decimal degrees
df <- dms_column_to_decimal(df, c("lat_Y", "long_X"))
# View the updated data frame
print(df)
} # }