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
Hi! I've been migrating a project to h3ronpy but I've been running into an issue returning the centroids of hexagons. It seems that the coordinates returned have exactly the same value:
importh3ronpyfromshapely.geometryimportPointfromh3ronpy.arrow.vectorimportgeometry_to_cells, cells_to_wkb_pointsimportpyarrowaspafromshapelyimportwkb# Step 1: Create a point (latitude and longitude)lat, lon=37.7749, -122.4194# Example coordinates (San Francisco)point=Point(lon, lat) # shapely expects (longitude, latitude)# Step 2: Convert the point to an H3 cell (resolution 9 for example)resolution=9h3_cells=geometry_to_cells(point, resolution)
# Step 3: Convert the H3 cell back to WKB pointswkb_points=cells_to_wkb_points(h3_cells)
# Step 4: Decode the WKB point to a Shapely geometryforwkb_pointinwkb_points:
ifisinstance(wkb_point, pa.Scalar): # Ensure it's a pyarrow Scalarshapely_point=wkb.loads(wkb_point.as_buffer().to_pybytes())
print(f"Shapely Geometry: {shapely_point}")
else:
print(f"Unexpected Type: {type(wkb_point)}")
Returns:
Shapely Geometry: POINT (-122.41827103692466 -122.41827103692466)
I'd be happy to help with the fix!
The text was updated successfully, but these errors were encountered:
Hi. Thanks for bringing this up (and the offer to help) - this is definitely a bug. I just checked and it happens with geopandas as well. I will look into this.
Seems having more tests would have helped to catch this earlier ;)
Hi! I've been migrating a project to
h3ronpy
but I've been running into an issue returning the centroids of hexagons. It seems that the coordinates returned have exactly the same value:Returns:
I'd be happy to help with the fix!
The text was updated successfully, but these errors were encountered: