h3-py
h3-py copied to clipboard
h3.h3shape_to_cells | Error message unclear
When reading some geojson files there are 3 coords, x, y, and z.
This breaks the call in:
h3.h3shape_to_cells
It is however still possible to make a h3.H3Poly
Repro
usa = gpd.read_file('https://raw.githubusercontent.com/scdoshi/us-geojson/master/geojson/nation/US.geojson')
usa = list(usa.geometry.iloc[0].geoms)[0]
print(usa.exterior.coords[:])
poly = h3.H3Poly(usa.exterior.coords[:])
print(poly.outer)
out = h3.h3shape_to_cells(poly, res=7)
Error
stderr
---
File "<udf>", line 39, in udf
File "/app/server_rt2/.venv/lib/python3.11/site-packages/h3/api/basic_str/__init__.py", line 427, in h3shape_to_cells
mv = _cy.polygon_to_cells(poly.outer, res, holes=poly.holes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "latlng.pyx", line 160, in h3._cy.latlng.polygon_to_cells
File "latlng.pyx", line 108, in h3._cy.latlng.GeoPolygon.__cinit__
File "latlng.pyx", line 77, in h3._cy.latlng.make_geoloop
ValueError: too many values to unpack (expected 2)