2017-01-26 11 views
0

指示された測定パッケージでデータを変換しようとしていますが、成功しません。測定パッケージを使用して地理座標を変換する

マイデータ:

Long  Lat 
62ᵒ36.080 58ᵒ52.940 
61ᵒ28.020 54ᵒ59.940 
62ᵒ07.571 56ᵒ48.873 
62ᵒ04.929 57ᵒ33.605 
63ᵒ01.419 60ᵒ30.349 
63ᵒ09.555 61ᵒ29.199 
63ᵒ43.499 61ᵒ23.590 
64ᵒ34.175 62ᵒ30.304 
63ᵒ16.342 59ᵒ16.437 
60ᵒ55.090 54ᵒ49.269 
61ᵒ28.013 54ᵒ59.928 
62ᵒ07.868 56ᵒ48.040 
62ᵒ04.719 57ᵒ32.120 
62ᵒ36.083 58ᵒ51.766 
63ᵒ01.644 60ᵒ30.714 
64ᵒ33.897 62ᵒ30.772 
63ᵒ43.604 61ᵒ23.426 
63ᵒ09.288 61ᵒ29.888 
63ᵒ16.722 59ᵒ16.204 

私は何をしようとしている:

警告メッセージ:

  1. 私はこの最後から二番目の行を取得しています何

    library(measurements) 
    
    library(readxl) 
    
    coord = read.table('coord_converter.txt', header = T, stringsAsFactors = F) 
    
    # change the degree symbol to a space 
    lat = gsub('°','', coord$Lat) 
    long = gsub('°','', coord$Long) 
    
    # convert from decimal minutes to decimal degrees 
    lat = measurements::conv_unit(lat, from = 'deg_dec_min', to = 'dec_deg') 
    long = measurements::conv_unit(long, from = 'deg_dec_min', to = 'dec_deg') 
    

    split(as.numeric(unlist(strsplit(x, " "))) * c(3600, 60), f = rep(1:length(x):で

  2. split.default(as.numeric(unlist(strsplit(x, " "))) * c(3600,longer object length is not a multiple of shorter object length
  3. data length is not a multiple of split variable

誰かが私のミスを指すか、続行する方法の提案を行うことができますか?

ありがとうございました!

答えて

0

私はこの問題はgsubコール後には、度と分がスペースで区切られていないことを、が要求したと考えていたと思います。例えば

が、これは(この再現性の例えば私も変わっ "ᵒ" を "°")を正常に動作します:

library(measurements) 

#read your data 
txt <- 
"Long  Lat 
62°36.080 58°52.940 
61°28.020 54°59.940 
62°07.571 56°48.873 
62°04.929 57°33.605 
63°01.419 60°30.349 
63°09.555 61°29.199 
63°43.499 61°23.590 
64°34.175 62°30.304 
63°16.342 59°16.437 
60°55.090 54°49.269 
61°28.013 54°59.928 
62°07.868 56°48.040 
62°04.719 57°32.120 
62°36.083 58°51.766 
63°01.644 60°30.714 
64°33.897 62°30.772 
63°43.604 61°23.426 
63°09.288 61°29.888 
63°16.722 59°16.204" 

coord <- read.table(text = foo, header = TRUE, stringsAsFactors = F) 

# change the degree symbol to a space 
lat = gsub('°',' ', coord$Lat) 
long = gsub('°',' ', coord$Long) 

# convert from decimal minutes to decimal degrees 
lat = measurements::conv_unit(lat, from = 'deg_dec_min', to = 'dec_deg') 
long = measurements::conv_unit(long, from = 'deg_dec_min', to = 'dec_deg') 

利回りを...

> cbind(long, lat) 
     long    lat    
[1,] "62.6013333333333" "58.8823333333333" 
[2,] "61.467"   "54.999"   
[3,] "62.1261833333333" "56.81455"   
[4,] "62.08215"   "57.5600833333333" 
[5,] "63.02365"   "60.5058166666667" 
[6,] "63.15925"   "61.48665"   
[7,] "63.7249833333333" "61.3931666666667" 
[8,] "64.5695833333333" "62.5050666666667" 
[9,] "63.2723666666667" "59.27395"   
[10,] "60.9181666666667" "54.82115"   
[11,] "61.4668833333333" "54.9988"   
[12,] "62.1311333333333" "56.8006666666667" 
[13,] "62.07865"   "57.5353333333333" 
[14,] "62.6013833333333" "58.8627666666667" 
[15,] "63.0274"   "60.5119"   
[16,] "64.56495"   "62.5128666666667" 
[17,] "63.7267333333333" "61.3904333333333" 
[18,] "63.1548"   "61.4981333333333" 
[19,] "63.2787"   "59.2700666666667" 
関連する問題