We've discovered that converting a valid H3 Index to a Placekey and then converting it back generates an invalid H3 Index. Here's a test example:
import { h3ToPlacekey, placekeyToH3 } from '@placekey/placekey'
import { isValidCell } from "h3-js"
const h3Input = "847b59dffffffff"
const placekey = h3ToPlacekey(h3Input)
const h3Output = placekeyToH3(placekey)
console.log({
validInput: isValidCell(h3Input),
h3Input,
placekey,
h3Output,
validOutput: isValidCell(h3Output),
})
Output:
{
validInput: true,
h3Input: '847b59dffffffff',
placekey: '@ff7-swh-m49',
h3Output: '8a7b59dffffffff',
validOutput: false
}
Note that the output index is only different in the 2nd digit; 4 changes to an a.
We first discovered this using the Carto spatial library for Snowflake, which uses Placekey and H3 under the covers: https://docs.carto.com/data-and-analysis/analytics-toolbox-for-snowflake/sql-reference/placekey. The same bug exists there.
We've discovered that converting a valid H3 Index to a Placekey and then converting it back generates an invalid H3 Index. Here's a test example:
Output:
Note that the output index is only different in the 2nd digit;
4changes to ana.We first discovered this using the Carto spatial library for Snowflake, which uses Placekey and H3 under the covers: https://docs.carto.com/data-and-analysis/analytics-toolbox-for-snowflake/sql-reference/placekey. The same bug exists there.