You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common use-case is to generate all hexagons that intersect with a given polygon. That's not straightforward to do using H3.
One approximate solution is to first generate a finer resolution grid using polyfill and then return to the desired resolution using h3_to_parent.
The H3-Pandas API could thus contain a convenience function that performs both of these operations in a single pass.
A quick demonstration of the idea:
importgeopandasasgpdimporth3pandasgdf=gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
# Resample to H3 cellsgdf=gdf.h3.polyfill_resample(4)
gdf=gdf.h3.h3_to_parent_aggregate(2)
Sidenote
The above code yields a "strange" result:
This is because a number of the hexagons cross the anti-meridian, and get rendered wrongly. Since this case might be reasonably common, H3-Pandas could perhaps provide a fix, something like
Please can you help. For which object to use the fix function?
when i use it for gdf, i get an error AttributeError: 'GeoSeries' object has no attribute 'coords'
Please can you help. For which object to use the fix function? when i use it for gdf, i get an error AttributeError: 'GeoSeries' object has no attribute 'coords'
The fix must be applied to the geometries themselves. I have added the relevant line to my post above.
A common use-case is to generate all hexagons that intersect with a given polygon. That's not straightforward to do using H3.
One approximate solution is to first generate a finer resolution grid using
polyfill
and then return to the desired resolution usingh3_to_parent
.The H3-Pandas API could thus contain a convenience function that performs both of these operations in a single pass.
A quick demonstration of the idea:
Sidenote
The above code yields a "strange" result:
This is because a number of the hexagons cross the anti-meridian, and get rendered wrongly. Since this case might be reasonably common, H3-Pandas could perhaps provide a fix, something like
Applying the fix to the dataframe's geometries
fixes the visual output
The text was updated successfully, but these errors were encountered: