Skip to content

GeoJSON Precision Loss Roundtrip

vectorGeoJSONPointEPSG:4326tinybundled

A GeoJSON dataset containing coordinates with very high precision that may lose accuracy during text serialization roundtrips. GeoJSON uses decimal text representation, and different serializers use different precision settings. This case exposes precision loss that can accumulate across multiple read/write cycles or cause coordinate drift.

Point geometry of precision_loss_geojson_roundtrip, rendered from the case's data
Point geometry, rendered from the case's actual geometry. Scale is normalized to the viewport and is not comparable between cases.
Property Value
Case ID precision_loss_geojson_roundtrip
Category vector
Format GeoJSON
Geometry type Point
CRS EPSG:4326
Location North Atlantic, off Bermuda — 122.42°W, 0.00°N → 10.12°E, 50.99°N
Test tier unit
Size class tiny
Storage class bundled
Redistributable yes
Loader geopandas
Status validated

Use this case

import pytest


@pytest.mark.geocase_case("precision_loss_geojson_roundtrip")
def test_precision_loss_geojson_roundtrip(geocase_case) -> None:
    data = geocase_case.load()
    assert data is not None

Use GeoCase in your tests

Install the complete set of vector, raster, and NetCDF dependencies:

pip install "geocase[all]"

View GeoCase on PyPI.

What this case checks

Expose precision loss during GeoJSON text serialization. Detect workflows where coordinates drift after multiple read/write cycles due to decimal precision limits. Compare against binary formats that preserve full IEEE 754 double precision.

Risk types covered

Expected behavior

Assertion Expected
expect_loadable yes
expect_valid_geometry yes
expect_crs yes
expected_epsg 4326
expected_geometry_types Point

Known consumer divergences

Disagreements already investigated on this case. If your reader reproduces one of these, it is catalogued — not a new finding.

gdal — GDAL d6fd56f52d (also GDAL 3.12.2), WKT and GeoJSON writers

Coordinates with |v| in [1e-14, 1e-13) are written as 0 by both the WKT and the GeoJSON writers -- relative error 1.0, silently, with no error and no warning. Not a precision floor: the default is 15 decimal places and 1e-14 is 0.00000000000001, 14 places. ogr/ogrlibjsonutils.cpp:158 formats through OGRFormatDouble(..., OGRWktOptions(15, round=true), 1), which calls intelliround at ogr/ogrutils.cpp:161-169; that branch tests s[len-3] through s[len-9] for zeros and then drops the last 8 characters, including the untested s[len-2], which for "0.000000000000010" holds the only significant digit. A brute force over 300000 coordinates puts the affected class at exactly [1e-14, 1e-13). Set SIGNIFICANT_FIGURES, or write a binary format, for coordinates in that class.

Upstream: https://github.com/farzinashouri/geocase/blob/main/docs/plans/44-gdal-as-target-and-the-numeric-axis.md

Notes

Purpose

This case tests coordinate precision preservation during GeoJSON text serialization. GeoJSON uses decimal string representation for coordinates, which can lose precision compared to binary IEEE 754 double representation.

Problem Demonstrated

GeoJSON precision challenges:

  1. Text vs Binary: Decimal text cannot exactly represent all floating-point values
  2. Serializer variance: Different libraries use different default precision (6-15 digits)
  3. Cumulative drift: Multiple read/write cycles can accumulate precision errors
  4. Comparison failures: High-precision coordinate comparisons may fail unexpectedly

Test Data

Three points with coordinates at IEEE 754 double precision limits:

Point Longitude Latitude Challenge
1 10.123456789012345 50.987654321098765 Full 15+ significant digits
2 -122.41941550000001 37.77492950000001 Trailing digits from binary representation
3 0.00000000000001 0.00000000000001 Very small values near zero

Expected Behavior

  • First read: Coordinates should load with maximum available precision
  • Roundtrip test: Write then read should preserve coordinates within tolerance
  • Multi-cycle test: N roundtrips should not accumulate unbounded drift

Precision Tolerances

Scenario Tolerance
Single roundtrip 1e-14 (sub-nanometer at equator)
10 roundtrips 1e-12 (acceptable drift)
Format comparison Binary formats (GPKG, WKB) should preserve full precision

Format-Specific Behavior

This is a GeoJSON-specific edge case:

  • GeoJSON: Text serialization, precision depends on serializer settings
  • GeoPackage: SQLite BLOB storage, full IEEE 754 precision
  • WKB: Binary format, full IEEE 754 precision
  • Shapefile: Double precision in SHP file, full IEEE 754 precision

GeoJSON's human-readable text format trades some precision for readability.

Required capabilities

  • load
  • geometry-validation
  • coordinate-precision-check

Files

Browse this case on GitHub

Source and license

  • Source: geocase-curated
  • License: MIT

Tags

coordinate_drift format_specific geojson precision roundtrip vector