-
Notifications
You must be signed in to change notification settings - Fork 309
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
feat(Gridintersect): new grid intersection options #1468
Conversation
docs(misc): clean up docstrings
for unsupported methods
ensure one entry per grid cell in polygon intersection result add test for this case
bug in structured mode where linestrings were not handled correctly if they pass in and out of grid cell
- fix vertices when intersecting linestring with offset grids
allow intersection shape to be passed as list of vertices (modify test to test this) specify keyword arguments explicitly in intersect calls formatting
- contains_centroid - min_area_fraction add tests
- add southeast diagonal neighbor in search if other neighbors produce no intersections - maintain intersection calculation order in result - add test
- add return_all_intersection options for points and linestrings on boundaries - improve plot_polygon method - black formatting and sort imports - add tests for return_all_intersections
- update example notebook
- parse result to only include polygons in _intersect_polygon_structured
I also wanted to deal with the shapely DeprecationWarning "ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0". But I was wondering what the policy is on backward compatibility for optional dependencies? The new methods needed to silence this warning are available from shapely 1.8.0 onwards. Do we continue supporting shapely<1.8 for a while, or can we break the code for older versions of shapely? Let me know, and i will commit a fix accordingly. |
Codecov Report
@@ Coverage Diff @@
## develop #1468 +/- ##
==============================================
- Coverage 74.970% 30.044% -44.927%
==============================================
Files 249 249
Lines 53645 52276 -1369
==============================================
- Hits 40218 15706 -24512
- Misses 13427 36570 +23143
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good overall. The only question I have is about the
sys.path.insert(1, "..")
call in t065_test_gridintersect.py. Is there a support script that is located within that path that is not explicitly installed into python?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this PR. @w-bonelli is going to remove the sys.path.insert()
call from t065 in his upcoming PR.
Sorry, the insert was just to get the code to use my fork instead of the installed flopy package. Thanks for dealing with that! Any advice on dealing with that shapely deprecation warning? |
It looks like we won't be able to use |
That would certainly be an option, but not sure if that would hurt performance. I'd prefer to go the method Shapely 2.0 suggests: geoms, items = self._get_gridshapes() # modify method to return geoms and cellids
self.strtree = strtree.STRtree(geoms, items)
# then get either geoms or cellids internally with:
self.strtree.query_geoms()
self.strtree.query_items() Only trouble is then we'd need to add logic for Shapely < 1.8 users if that is something we still want to support. I'd be okay with requiring shapely > 1.8 since it's an optional dependency anyway, but not sure how you guys think about that. PS. this is probably something for a new issue. |
I support requiring shapely > 1.8 unless it wasn't available for one of our supported operating systems. It looks like win, Mac, and linux are all supported. |
@dbrakenhoff I would say it would be fine to support |
Features:
min_area_fraction
kwarg for polygon intersections, keeping only results that cover a certain fraction of a grid cell (as discussed in GridIntersect fails with specific shapely Polygon due to change of nrow, ncol in the discretization object #1216)contains_centroid
kwarg for polygon intersections, keeping only results that contain cell centroid in intersection result (as discussed in GridIntersect fails with specific shapely Polygon due to change of nrow, ncol in the discretization object #1216)return_all_intersections
kwarg, which return all multiple intersection results for points and linestrings on cell boundaries (as discussed but not quite implemented in GridIntersect does not include cells with identical vertices, even with DISU #1198 and feat(GridIntersect): add optional kwarg to .intersect() to keep all c… #1214)Bug fixes:
Other improvements: