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

polygonToCells fails for some simple large polygons #191

Open
liujun3660105 opened this issue Jul 30, 2024 · 2 comments
Open

polygonToCells fails for some simple large polygons #191

liujun3660105 opened this issue Jul 30, 2024 · 2 comments

Comments

@liujun3660105
Copy link

when the polygon is very large,and the res is more than 0,then has error as follow:

image
@liujun3660105
Copy link
Author

for example:

const regionBox = {
  xmin: -180,
  ymin: -90,
  xmax: 0,
  ymax: 0
};
const polygon = [
  [regionBox.ymin, regionBox.xmin],
  [regionBox.ymax, regionBox.xmin],
  [regionBox.ymax, regionBox.xmax],
  [regionBox.ymin, regionBox.xmax]
];
const hexagons = h3.polygonToCells(polygon, 2);

@nrabinowitz
Copy link
Collaborator

This is currently the expected behavior, and should be better documented - the polygonToCells function will reject polygons with arcs > 180 degrees on longitude, because we do not currently enforce winding order so the area enclosed by the polygon is ambiguous (it could stretch across the antimeridian).

The workaround is to break very large polygons into smaller polygons with < 180 degrees of longitude.

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