Converting geo coordinates from degree to decimal

后端 未结 7 924
滥情空心
滥情空心 2020-11-28 10:48

I want to convert my geographic coordinates from degrees to decimals, my data are as follows:

         lat     long
105252 30°25.264 9°01.331
105253 30°39.23         


        
7条回答
  •  囚心锁ツ
    2020-11-28 11:21

    Another less elegant option using substring instead of strsplit. This will only work if all your positions have the same number of digits. For negative co-ordinates just multiply by -1 for the correct decimal degree.

    x$LatDD<-(as.numeric(substring(x$lat, 1,2))
    + (as.numeric(substring(x$lat, 4,9))/60))
    x$LongDD<-(as.numeric(substring(x$long, 1,1))
           + (as.numeric(substring(x$long, 3,8))/60))
    

提交回复
热议问题