Format geographical positions to degrees, minutes, and hemispheres

formatPosition(
  latlon,
  isLat = TRUE,
  type = c("list", "string", "expression"),
  showHemi = TRUE
)

Arguments

latlon

a vector of latitudes or longitudes

isLat

a boolean that indicates whether the quantity is latitude or longitude

type

a string indicating the type of return value (see below)

showHemi

a boolean that indicates whether to indicate the hemisphere

Value

A list containing degrees, minutes, seconds, and hemispheres, or a vector of strings or (broken) a vector of expressions.

Author

Dan Kelley

Examples

library(oce)
formatPosition(10 + 1:10 / 60 + 2.8 / 3600)
#> expression(c(10, 10, 10, 10, 10, 10, 10, 10, 10, 10), c(1, 2, 
#> 3, 4, 5, 6, 7, 8, 9, 10), c(2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 2.8, 
#> 2.8, 2.8, 2.8), c("N", NA, NA, NA, NA, NA, NA, NA, NA, NA), NULL, 
#>     NULL, NULL, NULL, NULL, NULL)
formatPosition(10 + 1:10 / 60 + 2.8 / 3600, type = "string")
#> expression("10 01' 2.80\" N", "10 02' 2.80\" NA", "10 03' 2.80\" NA", 
#>     "10 04' 2.80\" NA", "10 05' 2.80\" NA", "10 06' 2.80\" NA", 
#>     "10 07' 2.80\" NA", "10 08' 2.80\" NA", "10 09' 2.80\" NA", 
#>     "10 10' 2.80\" NA")