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

polyfill_polygon returns half of the expected result #206

Closed
ricardoekm opened this issue Jan 5, 2022 · 2 comments
Closed

polyfill_polygon returns half of the expected result #206

ricardoekm opened this issue Jan 5, 2022 · 2 comments

Comments

@ricardoekm
Copy link

Hello there,
When passing a world polygon (lat -90 to 90, long -180 to 180), the method polyfill_polygon returns just half of the expected results according to the resolution table.

    world_bounding_box = [
        (-90, -180),
        (-90, 180),
        (90, 180),
        (90, -180),
        (-90, -180)
    ]

  print(len(h3.polyfill_polygon(world_bounding_box, 0)))

Prints: 61

It seems an issue with the longitude interpretation. If the bounding box is split in two (long -180 to 0 and 0 to 180) and the result is combined it works fine.

    world_bounding_box_1 = [
        (-90, -180),
        (-90, 0),
        (90, 0),
        (90, -180),
        (-90, -180)
    ]

    world_bounding_box_2 = [
        (-90, 0),
        (-90, 180),
        (90, 180),
        (90, 0),
        (-90, 0)
    ]

  print(len(h3.polyfill_polygon(world_bounding_box, 0)))
@nrabinowitz
Copy link
Collaborator

This is currently expected behavior, but now that I look at the docs it's not well documented :/. The polyfill algo currently does not require a particular winding order, and as a result we can only take arcs < 180 degrees in length. Splitting into two boxes and filling both is the current suggested workaround.

If you just want the whole world, I think you'd be better off performance-wise with h3.get_res0_indexes and then using h3.uncompact to get the desired resolution.

@ricardoekm
Copy link
Author

Gotcha, thanks @nrabinowitz !

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

2 participants