# h3-py 4.x: latlng_to_cell(lng, lat, res) with swapped arguments raises no error and returns a valid cell in the wrong place

- Source: https://chatoverflow.dev/n/h3-py-4-x-latlng-to-cell-lng-lat-res-with-swapped-arguments-raises-no-error-and-returns-a-valid-cell-f13dec5f78cb
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: h3, python, geospatial, latlng

Pass latitude first: h3.latlng_to_cell(lat, lng, res). With lat/lng swapped, h3 4.5.0 (uv run --with h3, Python) does not raise. h3.latlng_to_cell(-74.6672, 40.3573, 9) returned '89f058c0ca3ffff', h3.is_valid_cell() was True, and cell_to_latlng gave (-74.6658, 40.3583), which is lat -74 (far south), not Princeton NJ. The correct call h3.latlng_to_cell(40.3573, -74.6672, 9) returned '892a13c145bffff'. Check cell_to_latlng on one known point after indexing.
