question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent "Inconsistent coordinate dimensionality" error

See original GitHub issue

As found in #963, there is a bit of inconsistency in how mixed 2D and 3D coordinates/points are used to create LineString objects.

These are expected errors:

from shapely.geometry import LineString, Point
import pytest

with pytest.raises(ValueError, match="Inconsistent coordinate dimensionality"):
    LineString([(1, 2, 3), (4, 5)])

with pytest.raises(ValueError, match="Inconsistent coordinate dimensionality"):
    LineString([Point(1, 2, 3), Point(4, 5)])

However these should also raise the error too:

with pytest.raises(ValueError, match="Inconsistent coordinate dimensionality"):
    LineString([(1, 2), (3, 4, 5)])

with pytest.raises(ValueError, match="Inconsistent coordinate dimensionality"):
    LineString([Point(1, 2), Point(3, 4, 5)])

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jorisvandenbosschecommented, Dec 12, 2022

Ah, a first regression report! 😉 Can you open a new issue with that failing example? (we clearly were not testing this case)

1reaction
jorisvandenbosschecommented, Aug 17, 2020

Indeed, I think that’s a correct analysis.

Now for a solution, note that pygeos already checks for this (although the error message is not very clear / user friendly, not sure we can do something about that …):

In [3]: pygeos.linestrings([(1, 2), (4, 5)])  
Out[3]: <pygeos.Geometry LINESTRING (1 2, 4 5)>

In [4]: pygeos.linestrings([(1, 2, 3), (4, 5)]) 
...
ValueError: linestrings: Input operand 0 does not have enough dimensions (has 1, gufunc core with signature (i, d)->() requires 2)

In [5]: pygeos.linestrings([(1, 2), (3, 4, 5)])  
...
ValueError: linestrings: Input operand 0 does not have enough dimensions (has 1, gufunc core with signature (i, d)->() requires 2)

So this will be fixed in Shapely 2.0 (and not necessarily worth doing a separate fix in 1.8, or at least not priority, I would say)

Read more comments on GitHub >

github_iconTop Results From Across the Web

#1079 (Inconsistent dimensionality change) – GEOS
It seems inconsistent all around, to me. What is the consistent rule supposed to be? My guess would have been "preserve the dimensionality...
Read more >
Failure while converting geojson to wkt · Issue #869 - GitHub
Steps to reproduce the problem. from shapely import geometry def ... dimensionality") ValueError: Inconsistent coordinate dimensionality.
Read more >
what is wrong with this shapely error message - Stack Overflow
I am using shapely for first time with no prior experience in it. Any help will be much appreciated. Thank you. Note: The...
Read more >
ValueError: Invalid coordinate dimensionality
I have looked for this error everywhere. Shapely did not provide anything about it. What I am trying to do is convert multiple...
Read more >
Why do I get the error "The input data has inconsistent size ...
Accepted Answer​​ The input data has inconsistent size. To resolve this error message, you must make sure that the matrices "xq", "yq" and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found