or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-parsing.mddepth-sonar.mdgps-positioning.mdindex.mdnavigation-course.mdproprietary-sentences.mdstream-processing.mdutilities.mdwind-weather.md

gps-positioning.mddocs/

0

# GPS Positioning Sentences

1

2

GPS positioning sentences provide location data, satellite information, and positioning quality metrics from GPS and GNSS receivers. These sentences form the core of most NMEA data streams from GPS devices.

3

4

## GGA - Global Positioning System Fix Data

5

6

Essential GPS fix information including position, altitude, and quality indicators.

7

8

```python { .api }

9

class GGA(TalkerSentence, ValidGGAFix, LatLonFix):

10

"""Global Positioning System Fix Data."""

11

12

timestamp: datetime.time

13

lat: str # Latitude in DDMM.MMMM format

14

lat_dir: str # 'N' or 'S'

15

lon: str # Longitude in DDDMM.MMMM format

16

lon_dir: str # 'E' or 'W'

17

gps_qual: str # GPS quality indicator (0-8)

18

num_sats: str # Number of satellites

19

horizontal_dil: str # Horizontal dilution of precision

20

altitude: float # Altitude above mean sea level

21

altitude_units: str # Units of altitude (usually 'M')

22

geo_sep: str # Geoidal separation

23

geo_sep_units: str # Units of geoidal separation

24

age_gps_data: str # Age of differential GPS data

25

ref_station_id: str # Reference station ID

26

27

@property

28

def latitude(self) -> float:

29

"""Latitude in signed decimal degrees."""

30

31

@property

32

def longitude(self) -> float:

33

"""Longitude in signed decimal degrees."""

34

35

@property

36

def is_valid(self) -> bool:

37

"""True if GPS quality indicates valid fix (1-5)."""

38

```

39

40

### GPS Quality Indicators

41

- **0**: Invalid

42

- **1**: GPS fix (SPS)

43

- **2**: DGPS fix

44

- **3**: PPS fix

45

- **4**: Real Time Kinematic

46

- **5**: Float RTK

47

- **6**: Estimated (dead reckoning)

48

- **7**: Manual input mode

49

- **8**: Simulation mode

50

51

### Usage Examples

52

53

```python

54

import pynmea2

55

56

# Parse GGA sentence

57

msg = pynmea2.parse("$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D")

58

59

print(f"Time: {msg.timestamp}") # 18:43:53.070000

60

print(f"Position: {msg.latitude}, {msg.longitude}") # -19.4840833333, 24.1751

61

print(f"Raw coordinates: {msg.lat}{msg.lat_dir}, {msg.lon}{msg.lon_dir}") # 1929.045S, 02410.506E

62

print(f"GPS Quality: {msg.gps_qual}") # 1 (GPS fix)

63

print(f"Satellites: {msg.num_sats}") # 04

64

print(f"HDOP: {msg.horizontal_dil}") # 2.6

65

print(f"Altitude: {msg.altitude} {msg.altitude_units}") # 100.0 M

66

print(f"Valid fix: {msg.is_valid}") # True

67

68

# Create GGA sentence

69

gga_data = ['184353.07', '1929.045', 'S', '02410.506', 'E', '1', '04', '2.6', '100.00', 'M', '-33.9', 'M', '', '0000']

70

new_msg = pynmea2.GGA('GP', 'GGA', gga_data)

71

print(str(new_msg)) # $GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D

72

```

73

74

## RMC - Recommended Minimum Specific GPS/TRANSIT Data

75

76

Minimum recommended navigation information including position, speed, course, and date.

77

78

```python { .api }

79

class RMC(TalkerSentence, ValidRMCStatusFix, LatLonFix, DatetimeFix):

80

"""Recommended Minimum Specific GPS/TRANSIT Data."""

81

82

timestamp: datetime.time

83

status: str # 'A' = Active, 'V' = Void

84

lat: str # Latitude in DDMM.MMMM format

85

lat_dir: str # 'N' or 'S'

86

lon: str # Longitude in DDDMM.MMMM format

87

lon_dir: str # 'E' or 'W'

88

spd_over_grnd: str # Speed over ground in knots

89

true_course: str # Track angle in degrees

90

datestamp: datetime.date # Date

91

mag_variation: str # Magnetic variation

92

mag_var_dir: str # Direction of magnetic variation

93

mode_indicator: str # Mode indicator (A, D, E, etc.)

94

nav_status: str # Navigational status

95

96

@property

97

def latitude(self) -> float:

98

"""Latitude in signed decimal degrees."""

99

100

@property

101

def longitude(self) -> float:

102

"""Longitude in signed decimal degrees."""

103

104

@property

105

def datetime(self) -> datetime.datetime:

106

"""Combined date and time."""

107

108

@property

109

def is_valid(self) -> bool:

110

"""True if status and mode indicators are valid."""

111

```

112

113

### Mode Indicators

114

- **A**: Autonomous mode

115

- **D**: Differential mode

116

- **E**: Estimated (dead reckoning) mode

117

- **F**: Float RTK mode

118

- **M**: Manual input mode

119

- **P**: Precise mode

120

- **R**: Real Time Kinematic mode

121

- **S**: Simulator mode

122

123

### Usage Examples

124

125

```python

126

import pynmea2

127

128

# Parse RMC sentence

129

msg = pynmea2.parse("$GPRMC,184353.07,A,1929.045,S,02410.506,E,0.13,309.62,120598,A*70")

130

131

print(f"Time: {msg.timestamp}") # 18:43:53.070000

132

print(f"Date: {msg.datestamp}") # 1998-05-12

133

print(f"Combined: {msg.datetime}") # 1998-05-12 18:43:53.070000

134

print(f"Status: {msg.status}") # A (Active)

135

print(f"Position: {msg.latitude}, {msg.longitude}") # -19.4840833333, 24.1751

136

print(f"Speed: {msg.spd_over_grnd} knots") # 0.13 knots

137

print(f"Course: {msg.true_course}°") # 309.62°

138

print(f"Valid: {msg.is_valid}") # True

139

```

140

141

## GLL - Geographic Position - Latitude/Longitude

142

143

Geographic position information with status and optional FAA mode indicator.

144

145

```python { .api }

146

class GLL(TalkerSentence, ValidStatusFix, LatLonFix):

147

"""Geographic Position - Latitude/Longitude."""

148

149

lat: str # Latitude in DDMM.MMMM format

150

lat_dir: str # 'N' or 'S'

151

lon: str # Longitude in DDDMM.MMMM format

152

lon_dir: str # 'E' or 'W'

153

timestamp: datetime.time # UTC time

154

status: str # 'A' = valid, 'V' = invalid

155

faa_mode: str # FAA mode indicator

156

157

@property

158

def latitude(self) -> float:

159

"""Latitude in signed decimal degrees."""

160

161

@property

162

def longitude(self) -> float:

163

"""Longitude in signed decimal degrees."""

164

165

@property

166

def is_valid(self) -> bool:

167

"""True if status is 'A'."""

168

```

169

170

### Usage Examples

171

172

```python

173

import pynmea2

174

175

# Parse GLL sentence

176

msg = pynmea2.parse("$GPGLL,1929.045,S,02410.506,E,184353.07,A,A*4C")

177

178

print(f"Position: {msg.latitude}, {msg.longitude}") # -19.4840833333, 24.1751

179

print(f"Time: {msg.timestamp}") # 18:43:53.070000

180

print(f"Status: {msg.status}") # A

181

print(f"FAA Mode: {msg.faa_mode}") # A

182

print(f"Valid: {msg.is_valid}") # True

183

```

184

185

## GNS - GNSS Fix Data

186

187

Combined GPS/GLONASS fix data with mode indicators for different satellite systems.

188

189

```python { .api }

190

class GNS(TalkerSentence, LatLonFix):

191

"""GNSS Fix Data."""

192

193

timestamp: datetime.time

194

lat: str # Latitude in DDMM.MMMM format

195

lat_dir: str # 'N' or 'S'

196

lon: str # Longitude in DDDMM.MMMM format

197

lon_dir: str # 'E' or 'W'

198

mode_indicator: str # Mode indicator for each system

199

num_sats: str # Number of satellites

200

hdop: str # Horizontal dilution of precision

201

altitude: str # Antenna altitude above geoid

202

geo_sep: str # Geoidal separation

203

age_gps_data: str # Age of differential data

204

diferential: str # Differential reference station ID

205

206

@property

207

def latitude(self) -> float:

208

"""Latitude in signed decimal degrees."""

209

210

@property

211

def longitude(self) -> float:

212

"""Longitude in signed decimal degrees."""

213

```

214

215

## GSA - GNSS DOP and Active Satellites

216

217

Satellite dilution of precision and active satellite information.

218

219

```python { .api }

220

class GSA(TalkerSentence, ValidGSAFix):

221

"""GNSS DOP and Active Satellites."""

222

223

mode: str # Selection mode (M = Manual, A = Auto)

224

mode_fix_type: str # Fix type (1 = None, 2 = 2D, 3 = 3D)

225

sv_id01: str # Satellite ID channel 1

226

sv_id02: str # Satellite ID channel 2

227

sv_id03: str # Satellite ID channel 3

228

sv_id04: str # Satellite ID channel 4

229

sv_id05: str # Satellite ID channel 5

230

sv_id06: str # Satellite ID channel 6

231

sv_id07: str # Satellite ID channel 7

232

sv_id08: str # Satellite ID channel 8

233

sv_id09: str # Satellite ID channel 9

234

sv_id10: str # Satellite ID channel 10

235

sv_id11: str # Satellite ID channel 11

236

sv_id12: str # Satellite ID channel 12

237

pdop: str # Position dilution of precision

238

hdop: str # Horizontal dilution of precision

239

vdop: str # Vertical dilution of precision

240

241

@property

242

def is_valid(self) -> bool:

243

"""True if fix type is 2D or 3D."""

244

```

245

246

### Usage Examples

247

248

```python

249

import pynmea2

250

251

# Parse GSA sentence

252

msg = pynmea2.parse("$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39")

253

254

print(f"Mode: {msg.mode}") # A (Auto)

255

print(f"Fix type: {msg.mode_fix_type}") # 3 (3D fix)

256

print(f"Active satellites: {[s for s in [msg.sv_id01, msg.sv_id02, msg.sv_id04, msg.sv_id05, msg.sv_id09, msg.sv_id12, msg.sv_id24] if s]}")

257

print(f"PDOP: {msg.pdop}") # 2.5

258

print(f"HDOP: {msg.hdop}") # 1.3

259

print(f"VDOP: {msg.vdop}") # 2.1

260

print(f"Valid: {msg.is_valid}") # True (3D fix)

261

```

262

263

## GSV - GNSS Satellites in View

264

265

Information about satellites in view including elevation, azimuth, and signal strength.

266

267

```python { .api }

268

class GSV(TalkerSentence):

269

"""GNSS Satellites in View."""

270

271

num_messages: str # Total number of GSV messages

272

msg_num: str # Current message number

273

num_sv_in_view: str # Total satellites in view

274

275

# Satellite 1 information

276

sv_prn_num_1: str # Satellite PRN number

277

elevation_deg_1: str # Elevation in degrees

278

azimuth_1: str # Azimuth in degrees

279

snr_1: str # Signal-to-noise ratio

280

281

# Satellite 2 information

282

sv_prn_num_2: str

283

elevation_deg_2: str

284

azimuth_2: str

285

snr_2: str

286

287

# Satellite 3 information

288

sv_prn_num_3: str

289

elevation_deg_3: str

290

azimuth_3: str

291

snr_3: str

292

293

# Satellite 4 information

294

sv_prn_num_4: str

295

elevation_deg_4: str

296

azimuth_4: str

297

snr_4: str

298

```

299

300

### Usage Examples

301

302

```python

303

import pynmea2

304

305

# Parse GSV sentence

306

msg = pynmea2.parse("$GPGSV,2,1,08,01,40,083,46,02,17,308,41,12,07,344,39,14,22,228,45*75")

307

308

print(f"Message {msg.msg_num} of {msg.num_messages}") # Message 1 of 2

309

print(f"Satellites in view: {msg.num_sv_in_view}") # 8

310

311

# Satellite 1 info

312

print(f"Sat {msg.sv_prn_num_1}: El={msg.elevation_deg_1}° Az={msg.azimuth_1}° SNR={msg.snr_1}")

313

# Sat 01: El=40° Az=083° SNR=46

314

315

# Process all satellites in this message

316

for i in range(1, 5): # GSV contains up to 4 satellites per message

317

prn = getattr(msg, f'sv_prn_num_{i}')

318

if prn:

319

elevation = getattr(msg, f'elevation_deg_{i}')

320

azimuth = getattr(msg, f'azimuth_{i}')

321

snr = getattr(msg, f'snr_{i}')

322

print(f"Satellite {prn}: Elevation={elevation}°, Azimuth={azimuth}°, SNR={snr}")

323

```

324

325

## Additional GPS Sentences

326

327

### GST - GNSS Pseudorange Error Statistics

328

329

```python { .api }

330

class GST(TalkerSentence):

331

"""GNSS Pseudorange Error Statistics."""

332

333

timestamp: datetime.time

334

rms: str # RMS value of standard deviation

335

std_dev_major: str # Standard deviation of semi-major axis

336

std_dev_minor: str # Standard deviation of semi-minor axis

337

orientation: str # Orientation of semi-major axis

338

std_dev_latitude: str # Standard deviation of latitude error

339

std_dev_longitude: str # Standard deviation of longitude error

340

std_dev_altitude: str # Standard deviation of altitude error

341

```

342

343

### GRS - GNSS Range Residuals

344

345

```python { .api }

346

class GRS(TalkerSentence):

347

"""GNSS Range Residuals."""

348

349

timestamp: datetime.time

350

residuals_mode: str # Residuals mode (0 = used, 1 = calculated)

351

sv_res_01: str # Satellite 1 residual

352

sv_res_02: str # Satellite 2 residual

353

# ... sv_res_03 through sv_res_12

354

sv_res_12: str # Satellite 12 residual

355

```

356

357

## Coordinate Conversion

358

359

All GPS positioning sentences that include LatLonFix mixin provide convenient coordinate conversion:

360

361

```python

362

import pynmea2

363

364

msg = pynmea2.parse("$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D")

365

366

# Decimal degrees (most common)

367

print(f"Lat: {msg.latitude}") # -19.4840833333

368

print(f"Lon: {msg.longitude}") # 24.1751

369

370

# Minutes and seconds components

371

print(f"Lat minutes: {msg.latitude_minutes}") # 29.045

372

print(f"Lon minutes: {msg.longitude_minutes}") # 4.506

373

print(f"Lat seconds: {msg.latitude_seconds}") # 2.7

374

print(f"Lon seconds: {msg.longitude_seconds}") # 0.36

375

376

# Format coordinates

377

print(f'{msg.latitude:.6f}°, {msg.longitude:.6f}°') # -19.484083°, 24.175100°

378

print(f'{abs(msg.latitude):.4f}°{msg.lat_dir}, {abs(msg.longitude):.4f}°{msg.lon_dir}') # 19.4841°S, 24.1751°E

379

```