Distance from empty collection is zero
See original GitHub issueExpected behavior and actual behavior.
Expected behaviour:
The distance from an empty collection should be +inf.
Actual behaviour:
The distance from an empty collection returns zero.
Steps to reproduce the problem.
Run the following script:
from shapely.geometry import Point, LineString
empty_thing = LineString()
assert empty_thing.is_empty
print(empty_thing.distance(Point(1, 1))) # Returns zero, should probably be +inf
Operating system
Windows 10 64 bit
Shapely version and provenance
Python 3.6 Shapely 1.6b4 installed from PyPI using pip
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Distance from empty collection is zero · Issue #498 - GitHub
Actual behaviour: The distance from an empty collection returns zero. Steps to reproduce the problem. Run the following script: from shapely.
Read more >If distance between the two sets is zero then their intersection ...
For example R+ and R− have distance 0, but there is no real number that is both positive and negative (but a limit...
Read more >On the indicators for perceiving empty sets as zero
The question whether human beings process empty sets as zero has received little research attention. In this study, we used the distance and...
Read more >How Far Can You Go on 0 Miles to Empty? - Car Roar
You can go about 25 – 50 miles (40 – 80 km) when the car says 0 miles. If your car is heavy...
Read more >What is the distance between any non-empty set and ... - Quora
which defines a distance between any two elements of the set. The metric has to have certain properties. If the set has zero...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Similar to GEOS, JTS returns 0.0, so perhaps this behavior was drafted a long time ago.
PostGIS returns
null
for this scenario, since there are not any geometries to measure between. I’d suggest Shapely similarly returnNone
if any of the inputs are empty.SQL Server spatial types return NULL, similar to PostGIS. Esri’s ArcPy generates an error. It seems we have 0, NULL, or error depending on whom you ask. I can see some merit behind arguments for any of them, so clear documentation is probably the most important part of addressing this issue. After all, without a consensus among geospatial products, it is a matter of expectations and not correctness.