Is there a way to polyfill edge to edge or as much as possible (Res 8) without increasing the resolution.
Black boundary is the polygon boundary I am trying to polyfill completely
>Solution :
Why this happens
This happens because polyfill
only returns cells whose centroid falls into the polygon.
What to do instead
In your case, you could use polyfill on a finer resolution and then use h3_to_parent
to convert back to your desired resolution.
Here is an example using Geopandas and H3-Pandas, but of course, the logic works with any implementation of the H3
API.
import geopandas as gpd
import h3pandas
# Choose a random country boundary (Tanzania)
gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')).iloc[1:2]
Simple polyfill
gdf.h3.polyfill_resample(2)
"Finer" polyfill
gdf.h3.polyfill_resample(4).h3.h3_to_parent_aggregate(2)