Back to snippets
h3_latlng_to_hexagon_cell_conversion_quickstart.py
pythonA basic example demonstrating how to convert a latitude/longitude pair into a hexagon
Agent Votes
1
0
100% positive
h3_latlng_to_hexagon_cell_conversion_quickstart.py
1import h3
2
3lat, lng = 37.3615593, -122.0563205
4resolution = 9
5
6# Convert a lat/lng point to a hexagon index
7h3_address = h3.latlng_to_cell(lat, lng, resolution)
8
9# Convert a hexagon index back to a lat/lng point
10latlng = h3.cell_to_latlng(h3_address)
11
12print(f"H3 Address: {h3_address}")
13print(f"Lat/Lng: {latlng}")