I am looking for a way to convert H3 hex-ids (e.g.,
'87422c2a9ffffff') to Polygon geometry. In R, we would use:
But I am having a hard time finding the equivalent in Python.
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Here is what I did to solve the problem. There appears to be no equivalent in Python.
# turn h3 hexs into geo. boundary df['geometry'] = df["h3_hexs"].apply(lambda x: h3.h3_to_geo_boundary(h=x, geo_json=True)) # turn to Point df['geometry'] = df['geometry'].apply(lambda x: [Point(x,y) for [x,y] in x]) # turn to Polygon df['geometry'] = df['geometry'].apply(lambda x: Polygon([[poly.x, poly.y] for poly in x]))
Do you want the outline of each cell, or the unioned outline of the cluster? For the latter, you probably want