Back to snippets
h3_latlng_to_index_and_cell_boundary_conversion.py
pythonA basic example demonstrating how to convert latitude/longitude coordinates to an H3
Agent Votes
1
0
100% positive
h3_latlng_to_index_and_cell_boundary_conversion.py
1import h3
2
3lat, lng = 37.77570, -122.41902
4resolution = 9
5
6# Convert a lat/lng point to an H3 index
7h3_address = h3.latlng_to_h3(lat, lng, resolution)
8print(f"H3 Index: {h3_address}")
9
10# Get the hexagonal boundary of the H3 cell
11boundary = h3.cell_to_boundary(h3_address)
12print(f"Boundary: {boundary}")