Closed ischlo closed 1 month ago
There is some confusion here - we could definitely be more explicit in the docs. The IJ coordinates are given in the same coordinate space as the origin, but they are not relative to the origin. So you need to get h3.cell_to_local_ij(origin, origin)
to get the origin's IJ coords in that space, then use that as the coords for your IJ offsets.
untested:
origin_i, origin_j = h3.cell_to_local_ij(origin, origin)
neighbs = [h3.local_ij_to_cell(origin=h3_cell, i=origin_i + id[0], j=origin_j + id[1]) for id in coords]
Hi Nick, Thanks for clarifying, Just to make sure, the function uses as origin the centre of the corresponding icosahedron in which the origin parameter cell lies ? Best, Ivann
De : Nick Rabinowitz @.> Envoyé : Friday, July 26, 2024 5:12:47 PM À : uber/h3-py @.> Cc : Schlosser, Ivann @.>; Author @.> Objet : Re: [uber/h3-py] local_ij_to_cell error (Issue #387)
There is some confusion here - we could definitely be more explicit in the docs. The IJ coordinates are given in the same coordinate space as the origin, but they are not relative to the origin. So you need to get h3.cell_to_local_ij(origin, origin) to get the origin's IJ coords in that space, then use that as the coords for your IJ offsets.
untested:
origin_i, origin_j = h3.cell_to_local_ij(origin, origin) neighbs = [h3.local_ij_to_cell(origin=h3_cell, i=origin_i + id[0], j=origin_j + id[1]) for id in coords]
— Reply to this email directly, view it on GitHubhttps://github.com/uber/h3-py/issues/387#issuecomment-2253075659, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANSJR2U3SOUXFWQHNJQCBLDZOJYP7AVCNFSM6AAAAABLQTS7ASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJTGA3TKNRVHE. You are receiving this because you authored the thread.Message ID: @.***>
Yes, that's correct, the IJ coordinates are centered on the face of the origin cell. But I'd recommend treating the coordinate system as opaque, i.e. only care about relative coordinates. It's still possible (but unlikely) that we could change the coordinate system under the hood, so it's better not to make assumptions in your code about where 0,0
is.
Hello, Unless I didn't understand what this function does, it is returning wrong values. I try to look at the ij neighbors of a cell to approximate a square shape, and the resulting set of cells are mapped in a completely different location, please find a reprex : I am using 'h3==4.0.0b3'.
Instead of plotting the ij neighbors of the cell in London, it plots in the middle of the ocean. Thanks for your help. Best, Ivann