Skip to content
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

H3 Polyfill skipping areas near the boundary #41

Open
nsehgal opened this issue Mar 20, 2019 · 5 comments
Open

H3 Polyfill skipping areas near the boundary #41

nsehgal opened this issue Mar 20, 2019 · 5 comments

Comments

@nsehgal
Copy link

nsehgal commented Mar 20, 2019

Hi I have noticed, when using polyfill for a polygon, it randomly skips certain areas near the boundary. How can we solve this?

For example. In this image blue dots are polygon side, and red is center. Notice the area in Cayote Point is not part of any polygon. So, polyfill will skip it even if that is part of the boundary.

Seems like if center is not part of boudary, it skips the whole polygon.

Screen Shot 2019-03-20 at 7 26 30 AM

@dfellis
Copy link
Collaborator

dfellis commented Mar 20, 2019

So assignment to a polygon is based on the location of the center points of the hexagons.

This was chosen because if you have two perfectly contiguous polygons, the entire hexagon grid will be assigned to only one polygon, instead of potentially two, maintaining the contiguous nature of the two polygons after the polyfill.

To get the behavior you appear to desire - any hexagon that touches the polygon is included - you can simply expand the polygon by the edge length of the hexagons. This page describes how to do this perfectly, but this simpler algorithm would probably suffice.

@rustyconover
Copy link

Actually expanding by the edge length is insufficient.

See:
https://observablehq.com/@rustyconover/ensuring-h3-polyfill-returns-all-hexagons-for-a-polygon

You may need to expand by edge length * 2.0.

@dfellis
Copy link
Collaborator

dfellis commented Apr 14, 2020

You only need to expand around the polygon by the edge length. You're confusing a border around an arbitrary polygon with a radius.

To create a border equal to the edge length for a circle you need to add 2 times the edge length to it, but the length of the distance between an arbitrary point on the circle and the closest point on the expanded circle would be just the edge length.

@kamil-kielczewski
Copy link

kamil-kielczewski commented Jan 17, 2022

@dfellis understanding and implementation Minkowski sum is quite time consumming. May be it will be better if we add some optional boolean parameter to polyfill function which as default will be work in old way - but if someone set it to true then the result will be minimal set of hexagons which cover input polygon?

That would save a lot of time for many people

@dfellis
Copy link
Collaborator

dfellis commented Jan 17, 2022

@dfellis understanding and implementation Minkowski sum is quite time consumming. May be it will be better if we add some optional boolean parameter to polyfill function which as default will be work in old way - but if someone set it to true then the result will be minimal set of hexagons which cover input polygon?

That would save a lot of time for many people

@kamil-kielczewski work has already started on adding multiple polyfill modes in the planned 4.0 of H3. If you wish to save a lot of time for many people, feel free to help getting this over the line sooner.

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

No branches or pull requests

4 participants