I have to convert coordinates from DMS (degrees, minutes and seconds) to DegDec (real numbers). However, the DMS separators are messed up, so I would like to split the columns on non-numeric characters excluding .
.
My data looks as follows:
lat | long |
---|---|
22ª29'56.06" | 105º21'37.27" |
22°29`53.14" | 105°21'29.48" |
22º30'00.43" | 105ª21'37.46'' |
105'29'27.17" | 105°21'39.68" |
The only pattern I can spot in the separators is that they are non-numeric and different from .
. I think I could solve this relatively easily if I could split these columns on non-numeric or period characters.
Once I have all three elements, I can concatenate them together to form a predictable pattern with the correct separators.
Here's a replicable sample from the data:
df <- tibble(lat=c("22ª29'56.06\"","22°29`53.14\"","22º30'00.43\"","105'29'27.17\""),
long=c("105º21'37.27\"","105°21'29.48\"","105°21'37.46\''","105°21'39.68"))