2

I am trying to run the following to test the st_hexagongrid function:

SELECT ST_HexagonGrid(10000, ST_Transform(ST_MakeEnvelope(10, 10, 11, 11, 4326), 3857))

But I am getting the following error:

ERROR:  function st_hexagongrid(integer, geometry) does not exist
LINE 2: SELECT ST_HexagonGrid(10000, ST_Transform(ST_MakeEnvelope(10...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 9

I did check my postgis version and it is 3.2:

SELECT PostGIS_Version();

3.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

Do you know any possible reasons for this issue?

4
  • your example works fine for me (automatically casting the size). Are other PostGIS functions working well? What do you get if you write \df st_hexagongrid in psql?
    – JGH
    Commented Sep 8, 2022 at 12:26
  • @JGH I am using server setup on Azure and not sure how to access psql. But I tried running this select proname,prosrc from pg_proc where proname like 'ST_HexagonGrid'; and doesn't return any records.
    – Shana
    Commented Sep 8, 2022 at 14:27
  • the proname would be in lowercase
    – JGH
    Commented Sep 8, 2022 at 14:47
  • @JGH with the like statement it doesn't really matter, anyways I tried with lower case select proname,prosrc from pg_proc where proname like 'st_hexagonGrid'; Same result...
    – Shana
    Commented Sep 9, 2022 at 5:20

1 Answer 1

0

The error occurs because you are passing as parameters an integer and a geometry, and the function requires a float and a geometry.

ST_HexagonGrid(float8 size, geometry bounds);

change to:

SELECT ST_HexagonGrid(10000::numeric, ST_Transform(ST_MakeEnvelope(10, 10, 11, 11, 4326), 3857))

check this error:

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

is telling you that it couldn't find a function that has this name or the types of arguments passed. It also asks to try to pass the arguments explicitly.

2
  • Thanks for the response but still get the error- ERROR: function st_hexagongrid(numeric, geometry) does not exist. LINE 2: SELECT ST_HexagonGrid(10000::numeric, ST_Transform(ST_MakeEn...
    – Shana
    Commented Sep 8, 2022 at 12:13
  • integer to float8 is an implicit cast, see pg_cast
    – JGH
    Commented Sep 8, 2022 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.