Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bug: typo shapely function call within gridintersect #2342

Closed
sannedesmet opened this issue Oct 22, 2024 · 3 comments · Fixed by #2343
Closed

bug: typo shapely function call within gridintersect #2342

sannedesmet opened this issue Oct 22, 2024 · 3 comments · Fixed by #2343
Labels

Comments

@sannedesmet
Copy link

Describe the bug
Within utils/grindintesect.py function "def _intersect_linestring_shapely2" the function shapely.multilinestring() is called in line 969.
However this function doesn't exist and should be changed to shapely.multilinestrings()

To Reproduce
Shapely with a version above 2 has to be installed.
In specific cases if multiple parts of a linestring are within one cell this function will be called
This is quite rare, that is the reason I think this bug is not noticed before, since it has been present for quite some releases of flopy.

Expected behavior
I expected a multilinestring as output, however I got the error as given below

Screenshots
image

@dbrakenhoff
Copy link
Contributor

Thanks @sannedesmet for the bug report, I would have thought this was captured by our tests, but I'll check it out and report back here!

Any chance you can share the shape/grid you are intersecting with?

@sannedesmet
Copy link
Author

Thanks for the quick reply @dbrakenhoff. I wanted to use a pull request to solve this bug, as it is relatively easy. However in the codecov file of flopy of a colleague I saw that the current test functions do not cover these specific lines. I got stuck writing a test, therefore I decided to write this issue.

The model that triggered this bug is quite large. It took me awhile to isolate the linestring that triggered the bug.
But this is the file: linestring_shapely2_bug.zip
The grid that corresponds to the error is a structured grid, with RD-coordinates: xmin = 103616, xmax = 105934, ymin =490937, ymax= 492815. With cellsize 2x2.

Is this sufficient or do you prefer a different way of sharing the grid?

dbrakenhoff added a commit to dbrakenhoff/flopy that referenced this issue Oct 22, 2024
- fix typo in shapely.multilinestrings
- fix issue with np.apply_along_axis
- consider geometry collections when computing overlaps
- add test for vertex mode
- add inactive test for structured mode (not yet working)
@dbrakenhoff
Copy link
Contributor

dbrakenhoff commented Oct 22, 2024

Thanks for reporting this @sannedesmet ! Good catch :).

The image below shows the culprits. And that makes sense. When the linestring touches/intersects the shape then comes out and then comes back to intersect at the vertex or is directly on the boundary that results in GeometryCollections. Fix is submitted through PR #2343.

image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants