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
hexify multipolygons #124
hexify multipolygons #124
Conversation
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
==========================================
+ Coverage 78.30% 82.32% +4.02%
==========================================
Files 15 15
Lines 742 758 +16
==========================================
+ Hits 581 624 +43
+ Misses 161 134 -27
Continue to review full report at Codecov.
|
# h3 hexes only work on polygons, not multipolygons | ||
source = source.explode() | ||
|
||
if type(source.unary_union) == Polygon: |
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.
We do expensive source.unary_union
here and then again in _to_hex
or in the loop below. In larger dataframes, that can cause a significant slowdown. My sense is that you spend most of the time actually doing unary union than anything else in this function, so we surely don't want to do it twice.
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.
good point, thanks. I added a new PR that switches to a try/except which should cut down one unary_union
call when it's not necessary, unless there's yet a more efficient way you can think of?
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.
For an approximate but faster solution, we could offer an option to simply cover the bounding box (or its alpha shape). That'd avoid the unary union and, in some cases, it should be the same.
Otherwise, I'd agree w/ @martinfleis: do the unary union once and re-use it if else
#125 is resolved by first exploding the input, then handling via split-apply-combine if the resulting unary_union is a multipolygon itself