beacen.

GPX internals field answer 033

Latitude, longitude and WGS 84 in GPX files

The short answer

GPX stores every point as required latitude and longitude attributes in decimal degrees, referenced to WGS 84. Latitude ranges from -90 to 90; longitude ranges from -180 up to but not including 180. Attribute order is irrelevant, signs matter, and extra decimal places show written precision rather than guaranteed real-world accuracy.

Every GPX point

Latitude and longitude place a point on the WGS 84 reference system.

A GPX waypoint, route point or track point must have two attributes: lat for latitude and lon for longitude. The GPX 1.1 schema specifies decimal degrees and the WGS 84 datum for both.

For example, lat="54.4541" lon="-3.2116" describes one horizontal position. Latitude measures north or south of the equator. Longitude measures east or west of the reference meridian. Positive latitude is north, negative latitude is south, positive longitude is east and negative longitude is west.

They are not eastings and northings, pixels or distances. A receiving map converts the geographic pair into whatever projection it uses for display.

Read them correctly

Latitude has the smaller range, but XML attribute order carries no meaning.

GPX latitude runs from -90 to 90 degrees inclusive. Longitude runs from -180 degrees inclusive to 180 degrees exclusive. Values outside those ranges do not conform to the GPX 1.1 schema.

  • Do not infer from positionXML attributes can be written in either order. Read the names lat and lon, not which appears first.
  • Keep the signDropping a minus sign moves a western longitude east of Greenwich or a southern latitude north of the equator.
  • Use decimal degreesDegrees, minutes and seconds must be converted before they are written as GPX coordinate attributes.
  • Check swapped pairsWhen both numbers happen to fit both ranges, a latitude-longitude swap can remain syntactically valid while placing the point somewhere else.

A map preview is the fastest sanity check. A valid number pair can still be the wrong number pair.

The reference frame

WGS 84 gives the numbers a shared geographic meaning.

A coordinate is useful only with a coordinate reference system. GPX fixes that horizontal reference as WGS 84 so exchanging software does not need to guess which datum the latitude and longitude use.

British National Grid coordinates use a different system and are normally expressed as eastings and northings. They cannot be pasted directly into GPX as if they were WGS 84 degrees. A proper coordinate transformation is needed. Ordnance Survey's coordinate-system guidance explains why conversion between WGS 84 and OSGB36 is more than renaming the two numbers.

WGS 84 says how to interpret the horizontal coordinates. It does not make the recorded position exact, and it does not settle the vertical reference of an optional <ele> value.

Digits are not certainty

Extra decimal places preserve a value more finely than they prove a position.

A coordinate written with seven decimal places is numerically more precise than one written with five. It does not prove that the receiver knew the location to that scale. Sensor conditions, satellite geometry, source-map alignment, snapping and later processing all affect positional accuracy.

  1. Confirm

    Check the point appears in the expected region.

    This catches missing signs, swapped fields and values copied from another coordinate system.

  2. Trace

    Inspect neighbouring points as a line.

    A single plausible coordinate can still sit out of order or create a spike in the route.

  3. Preserve

    Avoid casual rounding during conversion.

    Repeated rounding can move points and alter a detailed course even though each edit seems small.

  4. Separate

    Treat horizontal and vertical references independently.

    Correct WGS 84 latitude and longitude do not validate the source of the elevation value.

Sources & scope

What this answer is based on.

The GPX schema defines coordinate ranges, decimal degrees and WGS 84. Ordnance Survey explains why British grid coordinates require a proper reference-system transformation.