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.

See also

Examples

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