Skip to main content

pyrtcm

Current Status | Installation | Reading | Parsing | Generating | Serializing | Utilities | Examples | Extensibility | Command Line Utility | Graphical Client | Author & License

pyrtcm is an original Python 3 parser for the RTCM3 © GPS/GNSS protocol. RTCM3 is a proprietary GPS/GNSS differential correction or DGPS protocol published by the Radio Technical Commission for Maritime Services.

RTCM STANDARD 10403.n DIFFERENTIAL GNSS (GLOBAL NAVIGATION SATELLITE SYSTEMS) SERVICES – VERSION 3.

The pyrtcm homepage is located at https://github.com/semuconsulting/pyrtcm.

This is an independent project and we have no affiliation whatsoever with the Radio Technical Commission for Maritime Services.

FYI There are companion libraries which handle standard NMEA 0183 © and UBX © (u-blox) GNSS/GPS messages:

Current Status

Status Release Build Coverage Release Date Last Commit Contributors Open Issues

Parses RTCM3 messages into their constituent data fields - DF002, DF003, etc. Refer to the RTCM_MSGIDS dictionary in rtcmtypes_core.py for a list of message types currently implemented. Additional message types can be readily added - see Extensibility.

Sphinx API Documentation in HTML format is available at https://www.semuconsulting.com/pyrtcm/

Contributions welcome - please refer to CONTRIBUTING.MD.

Bug reports and Feature requests - please use the templates provided. For general queries and advice, post a message to one of the pyrtcm Discussions channels.

No Copilot


Installation

Python version PyPI version PyPI downloads

pyrtcm is compatible with Python >=3.10. In the following, python3 & pip refer to the Python 3 executables. You may need to substitute python for python3, depending on your particular environment (on Windows it's generally python).

The recommended way to install the latest version of pyrtcm is with pip:

python3 -m pip install --upgrade pyrtcm

If required, pyrtcm can also be installed into a virtual environment, e.g.:

python3 -m venv env
source env/bin/activate # (or env\Scripts\activate on Windows)
python3 -m pip install --upgrade pyrtcm

For Conda users, pyrtcm is also available from conda-forge:

Anaconda-Server Badge Anaconda-Server Badge

conda install -c conda-forge pyrtcm

Reading (Streaming)

class pyrtcm.rtcmreader.RTCMReader(stream, **kwargs)

You can create a RTCMReader object by calling the constructor with an active stream object. The stream object can be any data stream which supports a read(n) -> bytes method (e.g. File or Serial, with or without a buffer wrapper). pyrtcm implements an internal SocketStream class to allow sockets to be read in the same way as other streams (see example below).

Individual RTCM messages can then be read using the RTCMReader.read() function, which returns both the raw binary data (as bytes) and the parsed data (as a RTCMMessage, via the parse() method). The function is thread-safe in so far as the incoming data stream object is thread-safe. RTCMReader also implements an iterator.

The constructor accepts the following optional keyword arguments:

  • validate: VALCKSUM (0x01) = validate checksum (default), VALNONE (0x00) = ignore invalid checksum or length

  • quitonerror: ERR_IGNORE (0) = ignore errors, ERR_LOG (1) = log errors and continue (default), ERR_RAISE (2) = (re)raise errors and terminate

  • labelmsm: 1 = use RINEX code eg. "2C" (default), 2 = use Frequency band e.g. "L2" (see e.g. GPS-SIG-MAP). This argument affects the representation of CELLSIG values in RTCM3 MSM (multiple signal message) payloads:

    • labelmsm=1: CELLSIG_01=2C, CELLSIG_02=2W, CELLSIG_03=5I, etc.
    • labelmsm=2: CELLSIG_01=L2, CELLSIG_02=L2, CELLSIG_03=L5, etc.

Example A - Serial input, logging any errors and displaying any CELLSIG values in RINEX format:

from serial import Serial
from pyrtcm import RTCMReader, ERR_LOG
with Serial('/dev/tty.usbmodem14101', 9600, timeout=3) as stream:
  rtr = RTCMReader(stream, quitonerror=ERR_LOG, labelmsm=1)
  raw_data, parsed_data = rtr.read()
  if parsed_data is not None:
    print(parsed_data)
"<RTCM(1077, DF002=1077, DF003=0, DF004=204137001, DF393=1, DF409=0, DF001_7=0, ..., DF404_15=-9556, DF404_16=-2148, DF404_17=-2174)>",     

Example B - File input (using iterator) - this will terminate on error.

from pyrtcm import RTCMReader, ERR_RAISE
with open('rtcmdata.log', 'rb') as stream:
  rtr = RTCMReader(stream, quitonerror=ERR_RAISE, labelmsm=1)
  for raw_data, parsed_data in rtr:
    print(parsed_data)

Example C - Socket input (using iterator), ignoring any errors and displaying any CELLSIG values in Frequency band format:

import socket
from pyrtcm import RTCMReader, ERR_IGNORE
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as stream:
  stream.connect(("localhost", 50007))
  rtr = RTCMReader(stream, quitonerror=ERR_IGNORE, labelmsm=2)
  for raw_data, parsed_data in rtr:
    print(parsed_data)

Parsing

You can parse individual RTCM messages using the static RTCMReader.parse(data) function, which takes a bytes array containing a binary RTCM message and returns a RTCMMessage object.

NB: Once instantiated, an RTCMMessage object is immutable.

The parse() method accepts the following optional keyword arguments:

  • validate: VALCKSUM (0x01) = validate checksum (default), VALNONE (0x00) = ignore invalid checksum or length
  • labelmsm: 1 = use RINEX code eg. "2C" (default), 2 = use Frequency e.g. "L2".

Example:

from pyrtcm import RTCMReader
msg = RTCMReader.parse(b"\xd3\x00\x13>\xd0\x00\x03\x8aX\xd9I<\x87/4\x10\x9d\x07\xd6\xafH Z\xd7\xf7")
print(msg)
<RTCM(1005, DF002=1005, DF003=0, DF021=0, DF022=1, DF023=1, DF024=1, DF141=0, DF025=4444030.8028, DF142=1, DF001_1=0, DF026=3085671.2349, DF364=0, DF027=3366658.256)>

The RTCMMessage object exposes different public attributes depending on its message type or 'identity'. Attributes are defined as data fields (DF002, DF003, etc.) e.g. the 1097 multiple signal message (MSM) contains the following data fields:

print(msg)
print(msg.identity)
print(msg.DF248)
print(msg.DF404_07)
"<RTCM(1097, DF002=1097, DF003=0, DF248=204137001, DF393=1, DF409=0, DF001_7=0, DF411=0, DF412=0, DF417=0, DF418=0, DF394=216181732825628672, NSat=5, DF395=1073872896, NSig=2, DF396=1023, NCell=10, PRN_01=007, PRN_02=008, PRN_03=021, PRN_04=027, ..., DF404_07=5534, DF404_08=5545, DF404_09=-7726, DF404_10=-7733)>",             
'1097'
204137001
5534

Note that MSM message payloads comprise two discrete repeating groups - a 'SAT' group of size NSat relating to PRN (e.g. PRN_01=007, PRN_02=027, etc.), and a 'CELL' group of size NCell relating to a combination of PRN and Signal (e.g. CELLPRN_01=007, CELLSIG_01=1C, CELLPRN_02=007 CELLSIG_02=2C, CELLPRN_03=027, CELLSIG_03=1C, CELLPRN_04=027, CELLSIG_04=2C, etc.).

Attributes within repeating groups are parsed with a two-digit suffix (DF419_01, DF419_02, etc. See example below for an illustration of how to iterate through grouped attributes).

Helper methods are available to interpret the individual datafields:

from pyrtcm import RTCM_DATA_FIELDS, datadesc
dfname = "DF012"
print(RTCM_DATA_FIELDS[dfname])
print(datadesc(dfname))
(INT20, 0.0001, "GPS L1 PhaseRange - L1 Pseudorange")
'GPS L1 PhaseRange - L1 Pseudorange'

The payload attribute always contains the raw payload as bytes.

Iterating Through Group Attributes

To iterate through a group of one or more repeating attributes in a given RTCMMessage object, the following construct can be used (in this illustration, repeating attributes CELLPRN, CELLSIG, DF405, DF406, DF407, DF408, DF420 and DF404 are extracted from an MSM 1077 message msg and collated in the array msmarray):

msmarray = []
for i in range(msg.NCell): # msg = MSM 1077, number of cells = NCell
  vals = []
  for attr in ("CELLPRN", "CELLSIG", "DF405", "DF406", "DF407", "DF408", "DF420", "DF404"):
    val = getattr(msg, f"{attr}_{i+1:02d}")
    vals.append(val)
  msmarray.append(vals)
print(msmarray)
[['005', '1C', 0.00014309026300907135, 0.00014193402603268623, 341, 45.0, 0, -0.9231], ..., ['030', '2L', -0.00030865520238876343, -0.00030898721888661385, 341, 41.0, 0, -0.2174]]

The following dedicated helper methods are available to parse selected RTCM3 message types into a series of iterable data arrays:

  • parse_msm - for MSM message types (e.g. 1077, 1125, etc.).
  • parse_4076_201 - for 4076_201 SSR (harmonic coefficients) message types.

Generating

class pyrtcm.rtcmmessage.RTCMMessage(**kwargs)

You can create an RTCMMessage object by calling the constructor with the following keyword arguments:

  1. payload as bytes

Example:

from pyrtcm import RTCMMessage
msg = RTCMMessage(payload=b">\xd0\x00\x03\x8aX\xd9I<\x87/4\x10\x9d\x07\xd6\xafH ")
print(msg)
<RTCM(1005, DF002=1005, DF003=0, DF021=0, DF022=1, DF023=1, DF024=1, DF141=0, DF025=4444030.8028, DF142=1, DF001_1=0, DF026=3085671.2349, DF364=0, DF027=3366658.256)>

Serializing

The RTCMMessage class implements a serialize() method to convert a RTCMMessage object to a bytes array suitable for writing to an output stream.

e.g. to create and send a 1005 message type:

from serial import Serial
from pyrtcm import RTCMMessage
serialOut = Serial('COM7', 38400, timeout=5)
msg = RTCMMessage(payload=b">\xd0\x00\x03\x8aX\xd9I<\x87/4\x10\x9d\x07\xd6\xafH ")
print(msg)
output = msg.serialize()
print(output)
serialOut.write(output)
<RTCM(1005, DF002=1005, DF003=0, DF021=0, DF022=1, DF023=1, DF024=1, DF141=0, DF025=4444030.8028, DF142=1, DF001_1=0, DF026=3085671.2349, DF364=0, DF027=3366658.256)>
b'\xd3\x00\x13>\xd0\x00\x03\x8aX\xd9I<\x87/4\x10\x9d\x07\xd6\xafH Z\xd7\xf7'

Utility Methods

pyrtcm provides a number of utility methods (via the pynmeagps library), including:

  • ecef2llh - converts ECEF (X, Y, Z) coordinates to geodetic (lat, lon, ellipsoidal height) coordinates
  • llh2ecef - converts geodetic (lat, lon, ellipsoidal height) coordinates to ECEF (X, Y, Z) coordinates

See Sphinx documentation for details.


Examples

The following examples are available in the /examples folder:

  1. rtcmpoller.py - illustrates how to read and display RTCM messages 'concurrently' with other tasks using threads and queues. This represents a useful generic pattern for many end user applications.
  2. rtcmfile.py - illustrates how to stream RTCM data from binary log file.
  3. rtcmsocket.py - illustrates how to implement a TCP Socket reader for RTCM messages using RTCMReader iterator functionality.
  4. msmparser.py - illustrates how to parse RTCM3 MSM (multiple signal messages) into a series of iterable data arrays keyed on satellite PRN and signal ID.
  5. rtcm_ntrip_client.py - illustrates a simple NTRIP client using pyrtcm to parse the RTCM3 output.

Extensibility

The RTCM protocol is principally defined in the modules rtcmtypes_core.py and rtcmtypes_get.py as a series of dictionaries. RTCM uses a series of pre-defined data fields ("DF002", DF003" etc.), each of which has a designated data type (UINT32, etc.). Message payload definitions must conform to the following rules:

1. datafield names must be unique within each message class
2. datafield types must be one of the valid data fields ("DF026", "DF059", etc.)
3. repeating or bitfield groups must be defined as a tuple ('numr', {dict}), where:
   'numr' is either:
     a. an integer representing a fixed number of repeats e.g. 32
     b. a string representing the name of a preceding attribute containing the number of repeats e.g. 'DF029'
   {dict} is the nested dictionary of repeating items or bitfield group

Repeating attribute names are parsed with a two-digit suffix ("DF030_01", "DF030_02", etc.). Nested repeating groups are supported.


Command Line Utility

A command line utility gnssstreamer is available via the pygnssutils package. This is capable of reading and parsing NMEA, UBX and RTCM3 data from a variety of input sources (e.g. serial, socket and file) and outputting to a variety of media in a variety of formats. See https://github.com/semuconsulting/pygnssutils for further details.

To install pygnssutils:

python3 -m pip install --upgrade pygnssutils

For help with the gnssstreamer utility, type:

gnssstreamer -h

Graphical Client

A python/tkinter graphical GPS client which supports NMEA, UBX, RTCM3, NTRIP and SPARTN protocols is available at:

https://github.com/semuconsulting/PyGPSClient


Author & License Information

semuadmin@semuconsulting.com

License

pyrtcm is maintained entirely by unpaid volunteers. It receives no funding from advertising or corporate sponsorship. If you find the utility useful, please consider sponsoring the project with the price of a coffee...

Sponsor

Freedom for Ukraine

Metadata

Release files for pyrtcm 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyrtcm 1.2.0
File Size Uploaded
pyrtcm-1.2.0.tar.gz 101.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyrtcm 1.2.0
File Interpreter ABI Platform
pyrtcm-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 144.3 kB

Release files / pyrtcm-1.2.0.tar.gz

Download URL pyrtcm-1.2.0.tar.gz
Size 101.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3880a900292aeed6e3d053a68c20c6f183cabe0bd9ad65e74c2a08f4848cc5cc
BLAKE2b-256 checksum
How to use checksums
f0255be83be621241871d9ea8f802ed3058d1d874b8c12d2d222437e683bf817
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / pyrtcm-1.2.0-py3-none-any.whl

Download URL pyrtcm-1.2.0-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a76514d4c3189b9a1b3c77fed8bad73f69e76f1797b3536fdf42b8dee6bff7d1
BLAKE2b-256 checksum
How to use checksums
0787aff12fa74cde78c4eb1a622fdb0f7f059c7f6861711b23bb26adc7c0b1c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.12

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.11

2 release files

1.0.9

2 release files

1.0.8

1 release file

1.0.7

1 release file

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page