Test files › Geospatial › malformed-coords.geojson

Corrupt GeoJSON file (malformed coords)

GeoJSON that parses as JSON but violates the spec: a latitude of std 999 and a Polygon whose ring is not closed.

↓ Download malformed-coords.geojson
Filenamemalformed-coords.geojson
FormatGeoJSON
Size682 bytes (682 bytes)
MIME typeapplication/geo+json
SHA-2562690623c7de41f9f981408447b5c589bf067c1635bb4fe7d8e29af7af5c057c8
What this file catchesValidation beyond "is it JSON". A latitude above 90 and an unclosed polygon ring are both invalid per RFC 7946; a robust importer rejects or repairs them rather than plotting a point off the globe.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

GeoJSON is [longitude, latitude], polygon rings must close, and RFC 7946 (section 3.1.9) asks for lines that cross the 180th meridian to be split, or a map draws them the long way round the world.

import json

def points(c):
    if isinstance(c, list) and c and all(isinstance(v, (int, float)) for v in c):
        yield c
    elif isinstance(c, list):
        for item in c:
            yield from points(item)

def check(geom, n):
    kind, coords = geom.get("type"), geom.get("coordinates") or []
    for p in points(coords):
        if len(p) < 2 or not (-180 <= p[0] <= 180 and -90 <= p[1] <= 90):
            yield f"feature {n}: {p} is not [longitude, latitude] in range"
    if kind == "Polygon":
        for ring in coords:
            if len(ring) < 4 or ring[0] != ring[-1]:
                yield f"feature {n}: polygon ring is not closed (4+ positions, last equal to first)"
    if kind in ("LineString", "Polygon"):
        line = coords if kind == "LineString" else coords[0]
        for a, b in zip(line, line[1:]):
            if abs(a[0] - b[0]) > 180:
                yield f"feature {n}: {a} to {b} crosses the antimeridian; split it"

with open("malformed-coords.geojson", encoding="utf-8") as f:
    features = json.load(f)["features"]
found = [p for n, feat in enumerate(features, 1) for p in check(feat.get("geometry") or {}, n)]
print(f"{len(features)} features:", "valid" if not found else f"{len(found)} problem{'s' * (len(found) != 1)}")
for p in found:
    print("  " + p)

Run against this file, it prints: 2 features: 2 problems feature 1: [0, 999] is not [longitude, latitude] in range feature 2: polygon ring is not closed (4+ positions, last equal to first)

Related guides and tools

Sample GeoJSON, GPX and KML filesMIME typesVerify its SHA-256

Download & verify

curl -fsSL -o "malformed-coords.geojson" "https://files.hexaqa.com/geo/malformed-coords.geojson"
curl -fsSL "https://files.hexaqa.com/geo/malformed-coords.geojson" | sha256sum # expect: 2690623c7de41f9f981408447b5c589bf067c1635bb4fe7d8e29af7af5c057c8

More geospatial test files

antimeridian.geojsonplacemarks.kmlpoints.geojsontrack.gpx

← All Geospatial files