从GPS设备导入坐标(文本文件)

时间:2015-07-13 13:03:32

标签: r

如何仅从文本导入坐标(点,纬度和经度的名称)。 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

有什么想法吗?

1 个答案:

答案 0 :(得分: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