insert into hexgrids (id, params, tag) values ( 1, ( hex_OrientationFlat(), 3857, ST_SetSRID(ST_MakePoint(0, 0), 3857), ST_SetSRID(ST_MakePoint(500, 500), 3857) )::hexgrid, 'flat_grid_500x500' ), ( 2, ( hex_OrientationFlat(), 3857, ST_SetSRID(ST_MakePoint(10, 20), 3857), ST_SetSRID(ST_MakePoint(20, 10), 3857) )::hexgrid, 'flat_grid_20x10' ); select ST_SetSRID(ST_MakePoint(10000, 10000), 3857)::hexagon as hexagon; hexagon --------- (115,1) (1 row) select ST_AsText(ST_Centroid((28, 1)::hexagon)) as center; center ------------------------------ POINT(4500 4330.12701892219) (1 row) select ST_AsText(ST_Transform( (ST_Hexagon(ST_SetSRID(ST_MakePoint(-73.0, 40.0), 4326), 1))::geometry, 4326 )) as geom; geom ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- POLYGON((-72.9970999875523 40.0017510726044,-73.0015915639729 40.0017510726044,-73.0038373521832 39.9987713095566,-73.0015915639729 39.9957914164756,-72.9970999875523 39.9957914164756,-72.994854199342 39.9987713095566,-72.9970999875523 40.0017510726044)) (1 row) select morton_unpack((ST_Hexagon('SRID=3857;POINT(13 666)', 2)).code) as p1, morton_unpack((ST_Hexagon('SRID=3857;POINT(666 13)', 2)).code) as p2, morton_unpack((ST_Hexagon('SRID=3857;POINT(-13 -666)', 2)).code) as p3, morton_unpack((ST_Hexagon('SRID=3857;POINT(-666 -13)', 2)).code) as p4; p1 | p2 | p3 | p4 --------+----------+----------+--------- {0,37} | {22,-11} | {-1,-39} | {-22,9} (1 row)