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

Conversion into Feature Set #26

Open
chninja opened this issue Jan 22, 2022 · 4 comments
Open

Conversion into Feature Set #26

chninja opened this issue Jan 22, 2022 · 4 comments

Comments

@chninja
Copy link

chninja commented Jan 22, 2022

Hi,

I am doing a small prototype app for a research project of mine. I am running into an issue with h3SetToFeatureCollection where upon further inspection the coordinates are not even near the area of my polygon. I took a screen shot of the output cells of my polygon in h3 index longs and converted one of the hexagons into a lat long to verify that my hexagons where in the right area (New York coordinates). My coordinates once converted to h3SetToFeature are wrong and as a result not showing up on my map. I have a work around of just building my own function along with the h3 api functions. But I am wondering if I am just not doing something right.

Screen Shot 2022-01-22 at 1 33 13 PM

@chninja chninja changed the title Conversion into GSON Feature Set Conversion into Feature Set Jan 22, 2022
@nrabinowitz
Copy link
Collaborator

Can you paste in the inputs you're using? This is hard to diagnose from the screenshots.

My suspicion, however, is that you're running into this issue - it looks like the polygon arc from 145.56 longitude to -34.76 longitude crosses > 180 degrees of longitude and likely causes H3 to misinterpret the polygon.

I think I could fix this issue in geojson2h3 and h3-js, because we could take an optional param to determine shape based on winding order, but it might take some work, and would likely invoke a slower algorithm.

@chninja
Copy link
Author

chninja commented Jan 24, 2022

Hi,

Yes I can. This my code

      this.hexagons = geojson2h3.featureToH3Set(polygon, 10);
const geojson = geojson2h3.h3SetToFeatureCollection(Object.keys(this.hexagons), hex => ({value: 0.5}));

But I also used this with the same problem const geojson = geojson2h3.h3SetToFeature(this.hexagons[0]);.

Screenshot is the coordinates of the polygon and image of area.

Screen Shot 2022-01-24 at 2 58 25 PM

Screen Shot 2022-01-24 at 2 57 53 PM

The coordinates of my hexagon seem right. Is is the same issue as described above ?

@nrabinowitz
Copy link
Collaborator

const geojson = geojson2h3.h3SetToFeature(this.hexagons[0]) seems wrong, the input should be an array of strings, this looks like just a string.

geojson2h3.h3SetToFeatureCollection(Object.keys(this.hexagons), ...) seems wrong, because this.hexagons is an array of strings, so Object.keys(this.hexagons) is going to be a list of array indexes (as strings): ["0", "1", ...]

@chninja
Copy link
Author

chninja commented Jan 24, 2022

@nrabinowitz Well that was a simple fix! Thanks

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