Pikkola GeoJSON, tool No. 78

Coordinates, drawn and counted.

Paste a GeoJSON document or one WKT line and see what it actually contains: the bounding box, how many vertices, how long the line is, how large the polygon is, and whether every ring closes. The drawing is a plain equirectangular view with a graticule, which is enough to catch a swapped axis before it reaches a map.

7
geometry types
2
formats in
0
uploads

The atlas

Read it, then look at it

The numbers and the drawing come from the same parse, so a line that looks wrong is a line whose length is also wrong. Change the precision and both are recomputed rather than re-read.

The atlas

Nothing drawn yet.

Features
0
Geometries
0
Vertices
0
Read as
-
Bounding box
-
Centre
-
Length
-
Area
-
Bytes
-

Rounding to five decimals keeps about a metre.

Three numbers that catch a bad file

Most broken GeoJSON is not broken syntax. It is a document whose numbers are plausible and whose meaning is wrong, and three measurements find that faster than a zoomed-in map.

01

The bounding box first

A box that spans 300 degrees of longitude, or that sits at 37 degrees of longitude instead of latitude, is the fastest sign of a swapped pair. The box is computed once from the parsed positions, so it cannot disagree with the drawing.

02

Length and area, on the sphere

A line's length is the haversine sum over its segments and a polygon's area is the spherical excess of its rings, with holes subtracted. Both are kilometres, both are approximations of a shape the earth does not exactly have, and both are close enough to notice a factor of a thousand.

03

Rings, closed or not

Every ring is checked for the repeated first position and for four positions at minimum. A polygon that is open by one position draws in some libraries and never fills in others, which is exactly the bug that survives review.

What is read, and what is refused

The reader accepts the current specification and the one before it, refuses what cannot be drawn, and says which is which rather than quietly fixing a document.

Part of the document What this page does What it will not do
Geometry types Reads all seven, including GeometryCollection Guess a type from the shape of the coordinates
A null geometry Counts the feature and notes that it has no shape Drop the feature: the count has to match the file
An open ring Draws it and reports the two positions Close it for you: the file would stop matching the source
A crs member Ignores it and says so once Reproject anything: every coordinate is read as WGS 84
WKT Reads the same seven types, with Z, M and a SRID prefix Write every WKT dialect: the output is the OGC form
Precision Rounds to the decimals you choose and counts the bytes Simplify a line: rounding moves a vertex, it never removes one

The drawing is equirectangular and the scale is approximate. It is a check, not a map: there is no projection database here, and a small shape near a pole will look wider than it is.

Field guide

Coordinates, drawn and counted

GeoJSON looks like JSON and behaves like a map, and the mistakes that matter live between those two readings. This is what the format actually promises, where a plausible file goes wrong, and why the measurements on this page are the ones worth trusting before the drawing.

Every position is longitude first

A position is [longitude, latitude], in that order, on WGS 84. It is the single most common mistake in a hand-written file, because a map screen, a GPS log and most APIs say latitude first, and because a swapped pair is a valid position somewhere else on earth rather than an error. The range check catches only the pairs where one number is impossible as a longitude, which is why the bounding box is printed next to the drawing: a shape at 37 degrees of longitude and 127 of latitude is a real place in Korea, and it is not where the author meant.

An altitude may follow as a third number, and nothing else may. Four numbers in a position is a file from a database export, not a GeoJSON document, and a reader that silently accepts it will lose the fourth number somewhere downstream.

The type is the nesting

A Point is one position, a LineString is an array of positions, a Polygon is an array of rings and each ring is an array of positions. MultiPoint, MultiLineString and MultiPolygon add exactly one more level. There is no separate declaration of dimension: the depth of the arrays is the type, and a file whose arrays are one level off is either invalid or silently drawn as something else by a forgiving library. GeometryCollection is the one type that holds other geometries rather than coordinates, which is why it needs a different check.

TypeDepthA minimal valid shape
Point1[127.0, 37.5]
LineString2two positions
Polygon3one closed ring of four positions
MultiPolygon4an array of polygons

Rings have three rules and one convention

A ring must repeat its first position as its last, must contain at least four positions, and is written counter-clockwise for an outer ring and clockwise for a hole. The first two are in the specification and are checked here. The third is a convention that the specification recommends and that most renderers ignore, deriving inside from outside by a point-in-polygon test instead. When a polygon fills the wrong side of its own outline, the winding is the first thing to look at even though no validator will complain.

Length and area on a sphere

A length here is the sum of haversine distances between consecutive positions, with the earth's mean radius. That is accurate to about half a percent for the distances a line drawn by hand usually has, which is far better than the difference between a line that follows a road and one that does not. An area is the spherical excess of the ring, with holes subtracted, and it stays correct across the equator and the antimeridian where a planar formula does not. Both are approximations of an ellipsoid by a sphere; for a survey boundary the difference matters and for a delivery area it does not.

Why the preview is not a map

An equirectangular preview draws longitude as a straight horizontal axis and latitude as a straight vertical one, scaled by the cosine of the centre latitude. It has no coastlines, no tiles and no projection database, so it cannot show you where a shape is, only what shape it is and how its parts sit together. That is the right trade for this page: a projection library is several hundred kilobytes, the check is not, and the numbers beside the drawing carry the part a picture cannot.

When the trouble is the JSON rather than the geometry, Pikkola JSON formats and validates the same document. When the coordinates arrive as a table, Pikkola CSV reads that first.

Questions

Is my document uploaded anywhere?

No. The parser, the measurement and the drawing are JavaScript in this tab. The only request the page makes after it loads is the cookieless page-view count, which records that the page was opened and nothing about what is in it.

Why does my polygon draw but show no area?

Either the ring is not closed, or it has fewer than four positions, or the winding order puts the hole outside the shell. The findings panel names which of the three it is, with the positions that disagree. An area of zero with a visible outline is almost always an unclosed ring.

What projection is the preview using?

Equirectangular: longitude across, latitude down, with the horizontal axis scaled by the cosine of the centre latitude so a shape is not stretched sideways. It preserves nothing exactly, and it is the projection that makes a swapped axis obvious, which is the job here.

Why does it say my longitude is a latitude?

Because the number is outside the range a longitude can have. GeoJSON is longitude then latitude, and a file written from a screen that shows latitude first is the usual source. When both numbers are inside both ranges the check cannot tell, which is why the drawing exists.

Can I convert a shapefile or a KML file?

Not here: this reads GeoJSON and WKT, which are the two text formats a browser can read without a binary parser. A shapefile needs a .shp and a .dbf read together, and KML is XML with its own coordinate rules; a converter for either would be a different tool with a different promise.