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 not working, two different sets of Polygons #177

Open
tony-zeidan opened this issue Mar 2, 2021 · 5 comments
Open

Polyfill not working, two different sets of Polygons #177

tony-zeidan opened this issue Mar 2, 2021 · 5 comments

Comments

@tony-zeidan
Copy link

Hi there,

My application uses this library in order to take a shapefile of Canada and plot a grid of Hexagons (chloropleth map) and it seems when I use the same algorithm on two different shapefiles (sets of polygons), the polyfill returns the correct number of hexagons for one of them, and zero for the other. I have confirmed the issue has not to do with the resolution used. One of the shapefiles is just the provinces of Canada, and the other includes sea areas as well.
My code is the following.

    #obtain all hexagon locations
    h3_list = []
    exploded = canada_boundary.explode()
    print(exploded.head())
    for i, row in exploded.iterrows():
        poly_fill=h3.polyfill(exploded.geometry[i].__geo_interface__, H3_res,geo_json_conformant=True)
        print(len(poly_fill))
        for y in poly_fill:
            h3_list.append(y)


    megaFrame = pd.DataFrame(h3_list,columns=['h3_cell'])

Any advice would be appreciated, thanks!

Ask any questions necessary.

@ajfriend
Copy link
Contributor

ajfriend commented Mar 2, 2021

Could you point me to the shapefiles? Or, better yet, do you think you could reduce it to a minimal example?

@tony-zeidan
Copy link
Author

tony-zeidan commented Mar 2, 2021

Hi there, good to hear back from someone.

In this example, poly_fill returns 0 for every Polygon in the exploded shapefile. We explode the shapefile because h3.polyfill can only accept singular Polygons.

    #obtain all hexagon locations
    exploded = canada_boundary.explode()
    for i, row in exploded.iterrows():
        poly_fill=h3.polyfill(exploded.geometry[i].__geo_interface__, H3_res,geo_json_conformant=True)

The shapefiles can be found at
https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2011-eng.cfm

Ive only used the first two shape files, one being the provinces and territories cartographic and the other digital boundary.

@tony-zeidan
Copy link
Author

It may be the geo interface thing but it worked for one of the shapefiles.

@tony-zeidan
Copy link
Author

Please help, this issue is kind of pressing for me.

@deepweather
Copy link

deepweather commented May 20, 2021

I found this Explanation regarding my issue.

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