Back to Blog
    Geospatial Engineering

    Beyond the Blue Dot: GNSS Error Models, Kalman Filtering and Map Matching on Mobile Devices

    Marcus Rodriguez
    Dec 28, 2024
    9 min read
    Beyond the Blue Dot: GNSS Error Models, Kalman Filtering and Map Matching on Mobile Devices

    The blue dot on a map looks like a fact. It is actually an estimate — the output of a chain of measurements, models and filters, each with its own error characteristics. For consumer navigation, an error of fifteen metres is an annoyance. For a taxi fare computed from distance travelled, a geofence that unlocks a door or an automated attendance record, the same error becomes a billing dispute, a security incident or a payroll mistake.

    This article explains where positioning error comes from and the estimation techniques we use to build location-aware systems that make decisions automatically — and correctly.

    How a Phone Computes Its Position

    A GNSS receiver (GPS, Galileo, GLONASS or BeiDou) does not measure distance directly. Each satellite broadcasts its orbital parameters and a precise time stamp; the receiver measures when the signal arrives and multiplies the apparent travel time by the speed of light to obtain a pseudorange. It is "pseudo" because the receiver's inexpensive quartz clock is offset from the satellites' atomic clocks, and at the speed of light a clock error of one microsecond corresponds to roughly 300 metres.

    The receiver therefore solves for four unknowns — three position coordinates and its own clock bias — which is why at least four satellites are required. With more satellites in view the system is over-determined and is solved by iterative weighted least squares, linearising the range equations around the current estimate at each step.

    The geometry of the visible satellites matters as much as the quality of each individual measurement. Dilution of Precision (DOP) quantifies how measurement errors are amplified into position error: satellites clustered in one part of the sky yield a high DOP, while satellites spread across the sky yield a low one. To a first approximation, position error is the product of measurement error and DOP.

    The Error Budget

    The main error sources, roughly in order of importance on a phone, are:

    • Multipath and non-line-of-sight reception: in cities, signals reflect off buildings before reaching the antenna. A reflected signal travels further, so the pseudorange is too long. In dense urban canyons this produces errors of tens of metres and is the dominant problem.
    • Ionospheric delay: free electrons in the upper atmosphere slow the signal. The delay is inversely proportional to the square of the carrier frequency, which is why dual-frequency receivers can measure and remove it.
    • Tropospheric delay: water vapour and dry gases in the lower atmosphere add a delay that grows as a satellite approaches the horizon.
    • Orbit and clock errors: small residuals in the broadcast ephemeris and satellite clock corrections.
    • Receiver noise and antenna quality: smartphone antennas are small, linearly polarised and partly shielded by the user's hand, making them far more susceptible to multipath than survey-grade equipment.

    Under open sky a modern smartphone is typically accurate to about five metres. Between tall buildings the same device can be thirty metres or more off — and it frequently reports an optimistic accuracy value while doing so.

    Dual-Frequency and Raw Measurements

    Since 2018 a growing number of phones receive a second civil frequency: L5 for GPS and E5a for Galileo (1176.45 MHz), alongside the traditional L1/E1 (1575.42 MHz). Because ionospheric delay scales with 1/f², combining measurements on two frequencies removes the first-order ionospheric error. The L5 signal also has a ten-times-higher chipping rate than legacy L1 C/A, which makes it markedly better at rejecting multipath reflections.

    Android has exposed raw GNSS measurements — pseudoranges, Doppler shifts and, on supported chipsets, carrier phase — since Android 7.0. An application can therefore run its own positioning engine instead of trusting the chipset's black-box output, opening the door to Precise Point Positioning (PPP) with external correction data and, in favourable conditions, decimetre-level accuracy. Real-Time Kinematic (RTK) positioning, which combines carrier-phase measurements with a nearby reference station, reaches centimetre level on dedicated hardware, although smartphone antennas make robust RTK difficult in everyday conditions.

    Sensor Fusion with the Kalman Filter

    GNSS fixes arrive at about 1 Hz, are noisy and disappear entirely in tunnels and parking garages. Inertial sensors — accelerometer and gyroscope — sample at 100 Hz or more and are smooth over short intervals, but they drift quickly when integrated, because small biases are integrated twice to obtain position. The two are complementary, and the standard tool for combining them is the Kalman filter.

    A Kalman filter maintains a state estimate x (for example position, velocity, heading and sensor biases) together with a covariance matrix P describing its uncertainty. It alternates between two steps:

    • Predict: propagate the state with a motion model, x = F·x + B·u, and grow the uncertainty, P = F·P·Fᵀ + Q. Here F is the state-transition matrix, u the inertial input and Q the process noise, which expresses how far the motion model can be trusted.
    • Update: when a GNSS fix z arrives, compute the innovation y = z − H·x and the Kalman gain K = P·Hᵀ·(H·P·Hᵀ + R)⁻¹, where R is the measurement noise. The state becomes x + K·y and the uncertainty shrinks to (I − K·H)·P.

    The gain is the heart of the method: it weights every new measurement by the relative confidence of prediction and observation. Because vehicle and pedestrian motion is non-linear — a car moves along its heading, not along a fixed axis — real implementations use the Extended or Unscented variants, which linearise or deterministically sample the non-linear model around the current estimate.

    Two practical details separate robust filters from fragile ones:

    • Innovation gating: before accepting a fix, compute the squared Mahalanobis distance of the innovation, yᵀ·S⁻¹·y with S = H·P·Hᵀ + R. For a two-dimensional position it follows a chi-squared distribution with two degrees of freedom, so a threshold of about 9.21 rejects outliers at the 99% level. This is how a filter ignores a forty-metre multipath jump instead of following it.
    • Adaptive noise: R should not be constant. Scale it with the reported accuracy, the number of satellites used and their signal-to-noise ratio, and inflate it for the first fixes after a long outage.

    For vehicles, a zero-velocity update is equally valuable: when inertial data shows that the car is stationary at a traffic light, the filter clamps velocity to zero. This suppresses the familiar drift that otherwise adds phantom distance to a stationary vehicle.

    Map Matching with Hidden Markov Models

    Road vehicles offer one more powerful constraint: cars drive on roads. Map matching snaps a noisy trajectory onto the most probable sequence of road segments, and the most widely used formulation is the Hidden Markov Model introduced by Newson and Krumm (2009).

    The hidden states are candidate positions on nearby road segments; the observations are the GNSS fixes. Two probability models connect them:

    • Emission probability: how likely a fix is given a candidate road position, modelled as a Gaussian function of the distance between them.
    • Transition probability: how likely a move between two candidates in consecutive steps is, modelled as an exponential distribution over the difference between the straight-line distance of the two fixes and the driving distance along the road network. Real vehicles rarely make long detours between two samples, so candidates that would require one are penalised.

    The Viterbi algorithm then finds the globally most probable path in time linear in the number of fixes. Unlike nearest-road snapping, an HMM resolves parallel roads, overpasses and motorway ramps correctly, because it reasons about the trajectory as a whole rather than about each point in isolation.

    Why It Matters: Distance-Based Billing

    Consider a taxi or delivery fare computed from distance travelled. Summing the straight-line distances between raw GNSS fixes systematically overestimates the distance, because random position noise always adds length to a path and never removes it. At one fix per second, five metres of jitter while waiting at traffic lights can add hundreds of metres to a trip. Computing distance along the map-matched route, with zero-velocity updates suppressing stationary drift, produces fares that are both fairer and defensible in a dispute.

    Geofences That Do Not Flicker

    Automatic actions — starting a parking session, unlocking an entrance, recording arrival at a job site — are usually triggered by geofences. A naive implementation that fires whenever the estimate crosses a circle will flicker in and out as the position jitters around the boundary. Robust designs combine:

    • Hysteresis: separate entry and exit radii, so a user must be clearly inside to enter and clearly outside to leave.
    • Dwell time: the estimate must remain inside for a minimum period before an action is triggered.
    • Uncertainty-aware decisions: compare the distance to the boundary with the estimated accuracy, not with zero. Platform guidance points the same way: Android recommends geofence radii of at least 100–150 metres for reliable results.
    • Secondary confirmation: for security-relevant actions, combine the geofence with a short-range signal such as Bluetooth Low Energy or NFC, which proves proximity to within a few metres.

    Platform limits shape the architecture as well. iOS lets an application monitor at most twenty regions simultaneously, so systems with many sites must register the nearest ones dynamically as the user moves.

    Battery as an Engineering Constraint

    Continuous high-accuracy GNSS drains a battery within hours. Production applications use activity recognition (still, walking, in a vehicle) to adapt the sampling rate, fall back on low-power Wi-Fi and cell positioning when a coarse position is sufficient, batch location updates in hardware, and escalate to full-rate GNSS only as the user approaches a decision boundary. The result is a system that is precise exactly when precision matters.

    Privacy by Design

    Precise location is among the most sensitive categories of personal data. De Montjoye et al. (2013) showed that in a dataset of 1.5 million people, just four spatio-temporal points were enough to uniquely identify 95% of individuals. Good engineering therefore minimises what is collected in the first place:

    • Process on the device and transmit events ("arrived at site 14") rather than raw traces.
    • Coarsen stored positions — a six-character geohash corresponds to a cell of roughly 1.2 × 0.6 km and a seven-character geohash to about 150 × 150 m — and keep full resolution only where a use case justifies it.
    • Enforce retention limits and delete raw traces once derived values such as the billed distance are final.
    • Explain in plain language why location is needed, and request background access only when a feature genuinely requires it.

    Conclusion

    Reliable location-aware software is an estimation problem, not a lookup. Understanding the GNSS error budget, fusing satellite and inertial data in a well-tuned Kalman filter, constraining vehicles to the road network with probabilistic map matching, and designing geofences around uncertainty instead of ignoring it are what allow mobile systems to act automatically — and to be trusted when they do.