split() with polygon and linestring adds area outside of original polygon
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.5k
- Forks
- 631
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 10
Description
Expected behavior and actual behavior.
Expected split() to only split the input geometry, not add additional areas.
Steps to reproduce the problem.
from shapely import ops, wkt
poly = wkt.loads(
"POLYGON ((570.1990000000001 972.8950000000001, 579.11 972.8950000000001, 579.11 1028.8950000000002, 581.61 1028.8950000000002, 581.61 1062.8950000000002, 1331.61 1062.8950000000002, 1331.61 1067.3900000000003, 2653.8999999999996 1067.39, 2653.9 425.9100000000003, 2679.8010000000004 425.9100000000003, 2679.8010000000004 -484.29599999999994, 920.1990000000001 -484.29599999999994, 920.1990000000001 42.70400000000001, 734.11 42.70400000000001, 734.11 112.11499999999998, 570.1990000000001 112.11499999999998, 570.1990000000001 524.895, 579.11 524.895, 579.11 580.895, 581.61 580.895, 581.61 614.895, 734.11 614.895, 734.11 727.1150000000001, 570.1990000000001 727.1150000000001, 570.1990000000001 972.8950000000001))"
)
line = wkt.loads(
"LINESTRING (579.11 -640.4646, 579.11 1223.5586000000003, 581.61 1223.5586000000003, 581.61 -640.4646, 734.11 -640.4646, 734.11 1223.5586000000003, 920.1990000000001 1223.5586000000003, 920.1990000000001 -640.4646, 1331.61 -640.4646, 1331.61 1223.5586000000003, 2653.9 1223.5586000000003, 2653.9 -640.4646)"
)
result = ops.split(poly, line)
print(f"{poly.bounds[3]:0.2f}, {line.bounds[3]:0.2f}, {result.bounds[3]:0.2f}")
Output:
1067.39, 1223.56, 1223.56, i.e. the result has a larger bound than the input polygon.
Visualization:
Green area is the original polygon, the red line is the splitter, and the violet area is not part of the original polygon but it is returned by the split function.
Operating system
Ubuntu 22.04
Shapely version and provenance
2.0.2 installed from PyPI
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproducer from the issue with Shapely 2.0.2 and inspect the behavior of ops.split for the supplied polygon and linestring. Trace the split implementation and its geometry-processing dependency to identify why the result extends beyond the input polygon. Done means the result does not contain the reported additional area and the reproducer is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100