2015-07-13 64 views
0

如何僅從文本導入座標(點的名稱,經度和緯度)。有GPS輸出的小例子:從GPS設備導入座標(文本文件)

JB,NMTEPLOTY_A,DT08-30-2012,TM18:33:23 
MO,AD0,UN1,SF1.00000000,EC0,EO0.0,AU0 
--FAST Survey Version 3.0.3 
--CRD: Alphanumeric 
--UTM WGS84 Zone 34 
--Vybaveni: ProMark 100/120/200/220 
--Antenna Type: [ASH111661],RA0.0953m,SHMP0.0483m,L10.0754m,L20.0719m,--AT1675-539A 
--Lokaiz. soubor: Zadny 
--Soubor separace geoidu: Zadny 
--GPS meritko: 1.00000000 
--Scale Point not used 
--RTK Method: RTCM V3.0, Device: Internet/Telefon, Network: NTRIP SKPOS_CM_31 
BP,PNBP0000001,LA48.455805780000,LN19.473306486000,EL730.2370,AG0.000,PA0.000,-- 
--Entered HR: 2.1800, Vertical 
LS,HR2.2554 
GPS,PNT1,LA48.455791234500,LN19.473320912400,EL742.097500,-- 
--GS,PN**T1**,N **5402156.4131**,E **411272.6784**,EL739.8421,-- 
G0,08/30/2012 16:33:15,(Average) - Base ID read at rover: 0184 
G1,BPBP0000001,PNT1,DX9.538,DY6.564,DZ5.957 
G2,VX0.39187600,VY0.38068900,VZ0.43560000 
G3,XY-0.04224522,XZ-0.03550614,YZ-0.01908844 
--GT,PNT1,SW1703,ST405195700,EW1703,ET405195700 
--HRMS:0.879, VRMS:0.660, STATUS:FLOAT, SATS:6, PDOP:3.600, HDOP:1.600, VDOP:3.200 
--DT08-30-2012 
--TM18:33:24 
--Entered HR: 2.0300, Vertical 
LS,HR2.1054 
GPS,PNT2,LA48.455831723400,LN19.473281556600,EL732.594500,-- 
--GS,PN**T2**,N **5402169.0422**,E **411264.8433**,EL730.4891,-- 
G0,08/30/2012 16:37:17,(Average) - Base ID read at rover: 0184 
G1,BPBP0000001,PNT2,DX-2.484,DY-6.305,DZ7.055 
G2,VX1.16061620,VY0.70558220,VZ2.24236185 
G3,XY-0.55851595,XZ-1.13428888,YZ0.45677565 
--GT,PNT2,SW1703,ST405437400,EW1703,ET405437400 
--HRMS:1.343, VRMS:1.464, STATUS:FLOAT, SATS:7, PDOP:2.500, HDOP:1.500, VDOP:2.000 
--DT08-30-2012 
--TM18:37:22 
GPS,PNT3,LA48.455826060900,LN19.473298556100,EL738.839750,-- 
--GS,PN**T3**,N **5402167.2388**,E **411268.2855**,EL736.7343,-- 
G0,08/30/2012 16:38:57,(Average) - Base ID read at rover: 0184 
G1,BPBP0000001,PNT3,DX1.452,DY-1.199,DZ10.600 
G2,VX0.86879600,VY0.46316300,VZ2.23263940 
G3,XY0.01002715,XZ-0.87265410,YZ-0.07329004 
--GT,PNT3,SW1703,ST405537200,EW1703,ET405537200 
--HRMS:1.159, VRMS:1.501, STATUS:FLOAT, SATS:7, PDOP:2.500, HDOP:1.500, VDOP:2.000 
--DT08-30-2012 
--TM18:39:01 

我想這樣的座標列表:

T1 5402156.413 411272.6784 
T2 5402169.042 411264.8433 
T3 5402167.239 411268.2855 

任何想法?

+0

你可以告訴你試過嗎? –

+1

看看'?grep'和相關函數的家族。 –

+0

@VerenaHaunschmid - 我試過使用'tm'軟件包,但它遠沒有達到預期的結果。我只是一個初學者。 – Hawk81

回答

0

遠不是最優雅的解決方案,但它適用於您的示例數據。如果這個樣本不具代表性,它可能不適用於更大的數據集。

gpstxt <- "JB,NMTEPLOTY_A,DT08-30-2012,TM18:33:23 MO,AD0,UN1,SF1.00000000,EC0,EO0.0,AU0 --FAST Survey Version 3.0.3 --CRD: Alphanumeric --UTM WGS84 Zone 34 --Vybaveni: ProMark 100/120/200/220 --Antenna Type: [ASH111661],RA0.0953m,SHMP0.0483m,L10.0754m,L20.0719m,--AT1675-539A --Lokaiz. soubor: Zadny --Soubor separace geoidu: Zadny --GPS meritko: 1.00000000 --Scale Point not used --RTK Method: RTCM V3.0, Device: Internet/Telefon, Network: NTRIP SKPOS_CM_31 BP,PNBP0000001,LA48.455805780000,LN19.473306486000,EL730.2370,AG0.000,PA0.000,-- --Entered HR: 2.1800, Vertical LS,HR2.2554 GPS,PNT1,LA48.455791234500,LN19.473320912400,EL742.097500,-- --GS,PNT1,N 5402156.4131,E 411272.6784,EL739.8421,-- G0,08/30/2012 16:33:15,(Average) - Base ID read at rover: 0184 G1,BPBP0000001,PNT1,DX9.538,DY6.564,DZ5.957 G2,VX0.39187600,VY0.38068900,VZ0.43560000 G3,XY-0.04224522,XZ-0.03550614,YZ-0.01908844 --GT,PNT1,SW1703,ST405195700,EW1703,ET405195700 --HRMS:0.879, VRMS:0.660, STATUS:FLOAT, SATS:6, PDOP:3.600, HDOP:1.600, VDOP:3.200 --DT08-30-2012 --TM18:33:24 --Entered HR: 2.0300, Vertical LS,HR2.1054 GPS,PNT2,LA48.455831723400,LN19.473281556600,EL732.594500,-- --GS,PNT2,N 5402169.0422,E 411264.8433,EL730.4891,-- G0,08/30/2012 16:37:17,(Average) - Base ID read at rover: 0184 G1,BPBP0000001,PNT2,DX-2.484,DY-6.305,DZ7.055 G2,VX1.16061620,VY0.70558220,VZ2.24236185 G3,XY-0.55851595,XZ-1.13428888,YZ0.45677565 --GT,PNT2,SW1703,ST405437400,EW1703,ET405437400 --HRMS:1.343, VRMS:1.464, STATUS:FLOAT, SATS:7, PDOP:2.500, HDOP:1.500, VDOP:2.000 --DT08-30-2012 --TM18:37:22 GPS,PNT3,LA48.455826060900,LN19.473298556100,EL738.839750,-- --GS,PNT3,N 5402167.2388,E 411268.2855,EL736.7343,-- G0,08/30/2012 16:38:57,(Average) - Base ID read at rover: 0184 G1,BPBP0000001,PNT3,DX1.452,DY-1.199,DZ10.600 G2,VX0.86879600,VY0.46316300,VZ2.23263940 G3,XY0.01002715,XZ-0.87265410,YZ-0.07329004 --GT,PNT3,SW1703,ST405537200,EW1703,ET405537200 --HRMS:1.159, VRMS:1.501, STATUS:FLOAT, SATS:7, PDOP:2.500, HDOP:1.500, VDOP:2.000 --DT08-30-2012 --TM18:39:01" 

gpstxt <- gsub("GPS,", "\n", gpstxt) 
gpsdata <- read.table(text=gsub("N |E ","",gpstxt), skip = 1, fill = T, sep = ",")[,7:8] 
gpsdata <- format(gpsdata, digits = 15) # Restore display of decimals that have been truncated 

其中給出:

  V7   V8 
1 5402156.4131 411272.6784 
2 5402169.0422 411264.8433 
3 5402167.2388 411268.2855 
+0

優雅與否,它的作品:)。感謝您的時間! – Hawk81