conv_dm2dd: Convert DM coordinates values (sexagesimal) to DD (decimal...

View source: R/convert.r

conv_dm2ddR Documentation

Convert DM coordinates values (sexagesimal) to DD (decimal degree)

Description

This function is used to convert latitude and longitude from degrees, minutes format to decimal degree format, which is useful for map drawing.

Usage

conv_dm2dd(
  dm60,
  sep_marks = c(".", "-", "_", "u00b0"),
  out_original = FALSE,
  out_original_D = FALSE,
  out_original_M = FALSE
)

Arguments

dm60

sexagesimal numbers of character / numeric class.

sep_marks

a separation character between D and M part. Default: c(".", "-", "_", "u00b0")

out_original

include original values to output. Default: FALSE.

out_original_D

D (degrees) part on console to make sure the conversion is correct. Default: FALSE.

out_original_M

print M (minutes) part on console to make sure the conversion is correct. Default: FALSE.

Details

See example

Value

a vector of numeric class (default) or a data.frame if any output options are TRUE.

Examples

if(interactive()){
 numx <- c(34.30, 34.3, 34.03)
 conv_dm2dd(numx) # 34.50 34.50 34.05
 conv_dm2dd(numx, out_original_D = TRUE, out_original_M = TRUE)
 
 x <- c("35.30", "35.3", "35.03", "35", "30.30", "30.30.750")
 conv_dm2dd(x) # Make sure the last value equals (30 + 0.30750 / 60 * 100)
 
 x2 <- c("35°30′", "30°30.750′", NA, "35-30", "30-30.750", NA, "30_03")
 conv_dm2dd(x2)
 
 conv_dm2dd(x2, out_original = TRUE, out_original_D = TRUE, out_original_M = TRUE)
}

JK-junkin/frabento documentation built on Oct. 20, 2023, noon