pegas (version 0.12)

geoTrans: Manipulate Geographic Coordinates

Description

This function transforms standard geographical coordinates in degrees, minutes and seconds input as characters (or a factor) into numerical values in degrees.

Usage

geoTrans(x, degsym = NULL, minsym = "'", secsym = "\"")

Arguments

x

a vector of character strings storing geographical coordinates; this can be a factor with the levels correctly set.

degsym, minsym, secsym

a single character giving the symbol used for degrees, minutes and seconds, respectively.

Value

a numeric vector with the coordinates in degrees (eventually as decimal values).

Details

This function should be robust to any pattern of spacing around the values and the symbols (see examples).

If the letter S, W, or O is found is the coordinate, the returned value is negative.

Note that longitude and latitude should not be mixed in the same character strings.

The default for degsym (NULL) is because the degree symbol (<U+00B0>) is coded differently in different character encodings. By default, the function will use the appropriate character depending on the system and encoding used.

See Also

geod

Examples

Run this code
# NOT RUN {
coord <- c("N 43<U+00B0>27'30\"", "N43<U+00B0>27'30\"", "43<U+00B0>27'30\"N",
           "43<U+00B0> 27' 30\" N", "43 <U+00B0> 27 ' 30 \" N",
           "43<U+00B0>27'30\"", "43<U+00B0>27.5'")
cat(coord, sep = "\n")
geoTrans(coord)
geoTrans("43 D 27.5'", degsym = "D")
geoTrans("43<U+00B0> 27' 30\" S")
# }

Run the code above in your browser using DataCamp Workspace