pythonh3

get centroid latitude and longitude of h3 hexagon


I know ho to get h3 hexagon ids for various resolutions and add them to a pandas dataframe containing latitudes and longitudes. Is it possible to get the centroid latitude and longitude of each h3 hexagon given its id? I saw function but do not know how to use it in this context cell_to_latlng. Any pointers would be very much appreciated. thanks.

PS:

import h3
dir(h3)

does not show cell_to_lat_lng btw?!

This does not work:

from h3 import h3

h3.cell_to_lat_lng('88396c0331fffff')

I get:

AttributeError: module 'h3.api.basic_str' has no attribute 'cell_to_lat_lng'

Solution

  • There's currently a discrepancy between the docs and the released version of the h3-py library - the docs are for v4, but the released version is still v3 (v4 is in beta). In H3v3, the function you want is called h3_to_geo(hex_id).