[R] conversion of d m s (lat) d m s (long) coordinates into decimal coordinates

Nicolas Degallier n|co|@@@deg@|||er @end|ng |rom |ree@|r
Sun Apr 24 22:43:21 CEST 2022


Dear R Users,

I am using a 'simple' script to draw maps with points.
It runs fine with the following libraries:
library(sp)
library(maptools)
library(maps)
library(mapdata)
library(RColorBrewer)
library(MASS)
library(rgeos)
library(GISTools)

Until now, to prepare the input data, I have used manually some free net converter because the number of points to plot was not too high.
Now I have much more points coordinates to convert from a GPS ° ' " (d m s) format to a decimal format which will be accepted by the R script to build maps.

My initial data is of the form (tab delimited text file):

nom	lat	long
"D. antoinei"	6°04' S	50°12'W
"D. antoinei"	3°45'S	49°40'W
"D. antoinei"	3°1'49"N	53°6'24"W
"D. barberoi"	13°03.3’S	71°32.7’W
"D. barberoi"	10°59.3’S	75°25.5’W" 

and I need them in the format (tab delimited):

nom	lat	long
"D. antoinei"	-11.944478527683975	-71.28298997950684
"D. antoinei"	-12.833333	-69.333333
"D. antoinei"	3.333333	-60.283333
"D. barberoi"	-10.366667	-67.683333
"D. barberoi"	-15.314500	-55.970300

Is there some 'simple' R script to do such a conversion?
I am using R v. 3.2.1. on a iMac OS 10.6.8.

May be this topic had already been resolved but I was unable to find the result in the FAQs.
Cheers
Nicolas Degallier


<nicolas.degallier using free.fr>
<omalodes using yahoo.fr>

Publications :
https://www.documentation.ird.fr/listes/parauteur/DEGALLIER/NICOLAS/tout/annee



More information about the R-help mailing list