# Position log

The logging app I’m using is GPS Logger. I’m storing in GPX and KML files. Their formats are as follows:

Keyhole Markup Language: The KML. Is very simple, but also doesn’t offer much. It Looks like:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Document><name>2015-08-12T22:01:58Z</name><Placemark><gx:Track>
<!-- Then many repetitions looking like  -->
<when>2015-08-12T22:01:58Z</when>
<gx:coord>2.662407 49.23818433 147.0</gx:coord>

</gx:Track></Placemark></Document></kml>

GPS Exchange Format. The GPX format looks like:

<?xml version="1.0" encoding="UTF-8" ?>
<gpx version="1.0" creator="GPSLogger - http://gpslogger.mendhak.com/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0
http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>2015-08-12T22:01:58Z</time><trk><trkseg>

<!-- It then proceeds with repetitions of -->

<trkpt lat="49.24454858" lon="2.67159307">
<ele>148.0</ele>
<time>2015-08-12T22:02:32Z</time>
<course>45.2</course>
<speed>27.89</speed>
<src>gps</src>
<sat>22</sat>
<hdop>1.0</hdop>
<vdop>1.3</vdop>
<pdop>1.6</pdop>
<geoidheight>48.0</geoidheight>
</trkpt>

<!-- Mixed with repetitions of -->

<trkpt lat="52.4060613" lon="6.9069997">
<time>2015-08-13T21:38:19Z</time>
<src>network</src>
<sat>27</sat>
</trkpt>

</trkseg></trk></gpx>

After navigating the spec (combining version 1.0 with the more extensively documented 1.1), the following can be found:

Element Documentation
trkpt A Track Point holds the coordinates, elevation, timestamp, and metadata for a single point in a track.
lat The latitude of the point. Decimal degrees, WGS84 datum.
lon The longitude of the point. Decimal degrees, WGS84 datum.
ele Elevation (in meters) of the point.
time Creation/modification timestamp for element. Date and time in are in Univeral Coordinated Time (UTC), not local time! Conforms to ISO 8601 specification for date/time representation. Fractional seconds are allowed for millisecond timing in tracklogs.
course Instantaneous course at the point. (degrees, true) (only in 1.0)
speed Instantaneous speed at the point. (meters per second) (only in 1.0)
src Source of data. Included to give user some idea of reliability and accuracy of data. “Garmin eTrex”, “USGS quad Boston North”, e.g.
sat Number of satellites used to calculate the GPX fix.
hdop Horizontal dilution of precision.
vdop Vertical dilution of precision.
pdop Position dilution of precision.
geoidheight Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message.

Source:

## Dilution of precision

Measurements are never exact and always have an error. This modelled as either an interval, or a probability distribution around the true value. The hdop, vdop and pdop values provide an error estimate. According to wikipedia they are defined as:

\begin{aligned} \text{hdop} &= \sqrt{\sigma _{xx} + \sigma _{yy}} \\ \text{vdop} &= \sqrt{\sigma _{zz}} \\ \text{pdop} &= \sqrt{\sigma _{xx} + \sigma _{yy} + \sigma _{zz}} \end{aligned}

The $\sigma$’s are diagonal elements of the covariance matrix of the four space-time coordinates:

$\Sigma = \operatorname{cov} \begin{bmatrix} x \\ y \\ z \\ t \end{bmatrix} = \begin{bmatrix} \sigma _{xx} & \sigma _{yx} & \sigma _{zx} & \sigma _{tx} \\ \sigma _{xy} & \sigma _{yy} & \sigma _{zy} & \sigma _{ty} \\ \sigma _{xz} & \sigma _{yz} & \sigma _{zz} & \sigma _{tz} \\ \sigma _{xt} & \sigma _{yt} & \sigma _{zt} & \sigma _{tt} \end{bmatrix} = \Sigma ^T$

Since $\text{pdop}^2 = \text{hdop}^2 + \text{vdop}^2$ we really only have two values out of the ten that are relevant. And we are still missing a description of distribution of the errors. Bbzippo wrote about the error distribution. He/she mentions that the simple assumption of independent normally distributed coordinates agrees well with measurements. Let’s run with this assumption.

\begin{aligned} x &\sim N(\bar x, \sigma _{xx}) & y &\sim N(\bar x, \sigma _{yy}) & z &\sim N(\bar x, \sigma _{zz}) & t &\sim N(\bar x, \sigma _{tt}) \end{aligned}

For the elevation, $z$, we can directly use the distribution. For the time we have no error estimates whatsoever. The horizontal error is a bit more involved, we know $\sqrt{\sigma _{xx} + \sigma _{yy}}$ but not the individual values of $\sigma _{xx}$ and $\sigma _{yy}$. If we assume $\sigma _{xx} = \sigma _{yy} = \sigma$ then we can set $\sigma = ½\mathrm{hdop}^2$. We can move further and calculate the horizontal error distribution:

$\left\vert \begin{bmatrix} x \\ y \end{bmatrix} - \begin{bmatrix} \bar x \\ \bar y \end{bmatrix} \right\vert = \sqrt{ (x - \bar x)^2 + (y - \bar y)^2 } \sim \operatorname{Rayleight} (\sigma )$

## Data

cat *.csv | sort > full.csv
echo "time,longitude,latitude,elevation,hdop,vdop" > short.csv
awk 'NR % 100 == 0' full.csv >> short.csv

## Plot

• TODO: Give the countries a slight tint http://bl.ocks.org/jasondavies/4188334