-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: GridIntersect improvements #2344
Comments
Hi @dbrakenhoff, sounds like these are nice fixes. I think it's time to remove the shapely<2.0 code. I wonder if @mwtoews agrees? I'm also good with removing the structured mode. Doesn't seem like it's worth it to maintain. Regarding the GeoDataFrame return, should we add an optional argument to request that instead of returning based on whether or not geopandas is available? I think that could break our tests and examples. I think we will be switching more heavily to geopandas in the future, so maybe that would be a better time to make that type of change. |
I think it's fine to establish a minimum shapely 2.0, as it is widely available and replaces older shapely on all supported platforms. It should make code logic much easier to review. For the record, a key improvement with shapely 2.0 is that numpy arrays of geometries are supported, and processed much more efficiently using vectorized ufuncs written in C. |
Alright, I'll put something together and submit it for review.
And good point about this, I'll make it an option and we'll see what makes sense as geopandas becomes more integrated with flopy. |
This PR addresses #2344 and does the following: * Add DeprecationWarning when method != "vertex" * Remove all Shapely<2.0 code * Remove warnings filters for older numpy versions * Mark methods/tests that should be removed when method="structured" is officially removed * Ensure full test suite is maintained after removal of structured tests. * Move raster tests to a separate file. * Add option to return intersection results as (Geo)DataFrame * Allow plotting options to take as input GeoDataFrame (bit unnecessary as they have their own plotting logic) and improve plotting results. * Add plot_intersection_result() to plot result + modelgrid (optional). * Update example notebook. Note: Tests for 3D point intersections above/inside grid are deactivated. This is not yet working for method="vertex". Will probably be added in a separate PR.
Fix #2342: * 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) Notes: * np.apply_along_axis was reducing result from multiple GeometryCollections to a single MultiLineString causing duplication of shapes in the intersection result. * structured support will be dropped in future releases (see #2344)
I think merging those PRs auto-closed this, sorry @dbrakenhoff |
No worries, I guess we leave this open until we can remove the structured method and associated code? |
Some things I'd like to fix in gridintersect.py:
method="structured"
mode? This is somewhat complex to maintain, and performs worse than "vertex" mode in almost all cases, especially since Shapely 2.0 was released. This has the added advantage of "solving" the first issue in this list.I'm curious to hear your thoughts about these suggestions, so let me know what you think, and I can put together a PR!
The text was updated successfully, but these errors were encountered: