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.

intersection of linestring and polygen are wrong in some situations

See original GitHub issue
# # -*- coding: utf-8 -*-
from pygeos import set_operations
from pygeos import linestrings
from pygeos import polygons
import numpy as np

if __name__ == '__main__':
    area = np.array([[1240, 8], [70, 30], [70, 704], [1250, 689], [1240, 8]])
    area = polygons(area)

    edge1 = linestrings(np.array([[600, 117.1], [635, 117.1]]))
    intersection = set_operations.intersection(area, edge1)
    print(area, edge1, intersection)

    edge2 = linestrings(np.array([[600, 116], [635, 117.1]]))
    intersection = set_operations.intersection(area, edge2)
    print(area, edge2, intersection)

it works correctly in version 0.8.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jorisvandenbosschecommented, May 19, 2021

pygeos 0.10 was just released yesterday, and the wheels are built with GEOS 3.9.1. So you should be able to update to that.

1reaction
hehahacommented, May 19, 2021

I’m sorry about my expression, I’m not mean to be rude. I do don’t know this capital rule. Sorry about that.

As this problem, in 0.9 the output is:

POLYGON ((1.24e+03 8, 70 30, 70 704, 1.25e+03 689, 1.24e+03 8)) LINESTRING (600 117, 635 117) LINESTRING EMPTY
POLYGON ((1.24e+03 8, 70 30, 70 704, 1.25e+03 689, 1.24e+03 8)) LINESTRING (600 116, 635 117) LINESTRING (600 116, 635 117)

In 0.8, the output is:

POLYGON ((1.24e+03 8, 70 30, 70 704, 1.25e+03 689, 1.24e+03 8)) LINESTRING (600 117, 635 117) LINESTRING (600 117, 635 117)
POLYGON ((1.24e+03 8, 70 30, 70 704, 1.25e+03 689, 1.24e+03 8)) LINESTRING (600 116, 635 117) LINESTRING (600 116, 635 117)

And the weird thing is that intersection is wrong when I input a linestring with same y. Like (600 117, 635 117), same y as 117.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does shapely LineString intersection works wrong?
While working with shapely I faced a strange issue. There're 2 points p1 and p2, where the first one belongs to polygon and...
Read more >
Intersection gives wrong result · Issue #1216 · shapely/shapely
I ran into a case where an intersection between two (valid) (multi)polygons results in a wrong result. One example results in an "invalid" ......
Read more >
Polygon covered by the intersection of multiple linestrings ...
Polygonize the set of noded lines (this automatically discards any lines which do not form polygons); Compute the area of the polygonal result....
Read more >
The ST_Crosses() function - IBM
The ST_Crosses() function returns TRUE if the intersection object contains points that are interior to both source geometries, but is not equal to...
Read more >
Geography functions | BigQuery - Google Cloud
Functions that return TRUE or FALSE for some spatial relationship between two geographies or some property of a geography. These functions are commonly...
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