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

Incorrect result from polygonToCells for bigger screen/ higher dimensions #180

Closed
himanshupareek opened this issue Jul 26, 2023 · 6 comments

Comments

@himanshupareek
Copy link

Hi team,

For bigger screens (4k resolutions -> 2560 px), this method polygonToCells is responding with wrong H3 Cells ( We are just getting bounding box as input and converting that into polygon and passing within this method to get the H3 Cells).
While we are expecting the data for Europe, Africa, Middle East etc, it is responding with opposite area's H3 Cells (North America, Japan, China etc..)

This issue starts from the resolution 2105 px. Before that till 2104 px everything works as expected.

Requested Bounding box:

15.203087,-109.629878,72.791223,110.448247 (Lat/lng)
-109.629878,15.203087,110.448247,72.791223 (Lng/Lat)

Bounding box representation on third party site - http://bboxfinder.com/

image

Received H3Cells:

Screenshot of Kepler:

image

Please let us know if you can help us on this issue. Its a bit urgent!! Thanks.

@nrabinowitz
Copy link
Collaborator

This isn't related to screen resolution, but to the width of the bounding box. If your polygon has an edge that crosses more than 180 degrees of longitude, we use the smaller interpretation (the alternative was to require a particular winding order, which is tricky because there isn't one standard).

To work around this limitation, break large bounding boxes horizontally into two separate boxes with less than 180-degree widths.

@himanshupareek
Copy link
Author

Thanks @nrabinowitz , I will check and will confirm here, if that works for me, thanks.

@himanshupareek
Copy link
Author

The suggested solution worked, so I am closing this ticket. Thanks @nrabinowitz for quick support.

@indus
Copy link

indus commented Nov 10, 2023

the alternative was to require a particular winding order, which is tricky because there isn't one standard

Are you refering to GeoJSON? Because rfc7946:

Polygon
A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

I think at least when isGeoJSON is set to true polygonToCells should not use an interpretation.

@nrabinowitz
Copy link
Collaborator

the alternative was to require a particular winding order, which is tricky because there isn't one standard

Are you refering to GeoJSON? Because rfc7946:

Polygon
A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

I think at least when isGeoJSON is set to true polygonToCells should not use an interpretation.

No, I'm referring to geospatial formats in general - see e.g. the discussion here. ESRI Shapefiles and other formats use clockwise order for external rings.

The choice about winding order enforcement is made in the core H3 library, not h3-js, and the core library has no idea of GeoJSON or other formats as input - it specifies an input shape with lat,lng coordinate order and no predefined winding order. The h3-js library, and the Python bindings, offer some GeoJSON support specifically to allow input in lng,lat order (still passed to the core lib as lat,lng), but the isGeoJSON flag in the bindings isn't going to affect core library processing.

@indus
Copy link

indus commented Nov 11, 2023

@nrabinowitz thanks for that explanation.

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

3 participants