elastic/elasticsearch · error · ParseException
coordinate dimensions do not match: {}
Error message
coordinate dimensions do not match: {} What it means
Thrown by WellKnownText.parseCoordinate when, within a single geometry, some coordinate tuples include an altitude (third number) and others do not. The method accumulates lons, lats, and alts; if alts is non-empty but its size differs from lons, the dimensions are inconsistent.
Source
Thrown at libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownText.java:524
}
static void parseCoordinates(StreamTokenizer stream, ArrayList<Double> lats, ArrayList<Double> lons, ArrayList<Double> alts)
throws IOException, ParseException {
parseCoordinate(stream, lats, lons, alts);
while (nextCloserOrComma(stream).equals(COMMA)) {
parseCoordinate(stream, lats, lons, alts);
}
}
static void parseCoordinate(StreamTokenizer stream, ArrayList<Double> lats, ArrayList<Double> lons, ArrayList<Double> alts)
throws IOException, ParseException {
lons.add(nextNumber(stream));
lats.add(nextNumber(stream));
if (isNumberNext(stream)) {
alts.add(nextNumber(stream));
}
if (alts.isEmpty() == false && alts.size() != lons.size()) {
throw new ParseException("coordinate dimensions do not match: " + tokenString(stream), stream.lineno());
}
}
private static MultiPoint parseMultiPoint(StreamTokenizer stream) throws IOException, ParseException {
String token = nextEmptyOrOpen(stream);
if (token.equals(EMPTY)) {
return MultiPoint.EMPTY;
}
ArrayList<Double> lats = new ArrayList<>();
ArrayList<Double> lons = new ArrayList<>();
ArrayList<Double> alts = new ArrayList<>();
ArrayList<Point> points = new ArrayList<>();
parseCoordinates(stream, lats, lons, alts);
for (int i = 0; i < lats.size(); i++) {
if (alts.isEmpty()) {
points.add(new Point(lons.get(i), lats.get(i)));
} else {
points.add(new Point(lons.get(i), lats.get(i), alts.get(i)));View on GitHub (pinned to db6a809a66)
Solutions
- Make all coordinate tuples in the geometry the same dimensionality: either all 2D (remove altitudes) or all 3D (add the missing altitude).
- If the source data is heterogeneous, normalize it before WKT generation so every tuple has the same number of components.
- Validate each tuple's component count during generation and log/skip inconsistent rows.
Example fix
// before: mixed 2D/3D tuples
Geometry g = WellKnownText.fromWKT("LINESTRING (0 0 1, 1 1)");
// after: consistent 3D
Geometry g = WellKnownText.fromWKT("LINESTRING (0 0 1, 1 1 0)");
// or consistent 2D
Geometry g = WellKnownText.fromWKT("LINESTRING (0 0, 1 1)"); Defensive patterns
Strategy: validation
Validate before calling
// Validate that all coordinate tuples in a WKT body have equal arity
static void validateTupleArity(String wktBody) {
// extract tuples inside parentheses, split on commas, count numeric tokens per tuple
// ensure all tuples have the same component count (2 or 3)
} Try / catch
try {
Geometry g = WellKnownText.fromWKT(wkt);
} catch (java.text.ParseException e) {
if (e.getMessage().contains("coordinate dimensions do not match")) {
// normalize source tuples to uniform dimensionality
}
throw e;
} Prevention
- Normalize source data so every tuple has the same number of components.
- When merging datasets, reconcile dimensionality before WKT generation.
- Log tuples that deviate from the expected arity during ETL.
When it happens
Trigger: A WKT geometry where coordinate tuples have mixed arity, e.g. "LINESTRING (0 0 1, 1 1)" — the first tuple has 3 values (altitude added to alts) but the second has only 2 (no altitude), so alts.size() (1) != lons.size() (2).
Common situations: CSV-to-WKT conversion where a row is missing its elevation column; data merged from sources with different dimensionality; a serialization bug that drops the Z value on some tuples; upstream truncation.
Related errors
- When specifying 'Z' or 'M', coordinates must include three v
- maximum nested depth of 1000 exceeded
- expected word but found: {}
- invalid number found: {}
- expected number but found: {}
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/ab2e5cc8f680a3f8.
Report an issue: GitHub.