1

Having a hard time to get a raster from a polygon

ST_AsRaster(ST_Buffer(ST_GeomFromText('POLYGON((-30 40, -20 30, -25 20, -23 10, -30 40))', 4326), 50),ARRAY['8BUI'],ARRAY[118]);

This line is giving me an error : No function matches the given name and argument types. You might need to add explicit type casts.

1 Answer 1

3

You are missing pixel dimensions:

CREATE EXTENSION IF NOT EXISTS postgis_raster;

SELECT ST_AsRaster(
   ST_Buffer(ST_GeomFromText('POLYGON((-30 40, -20 30, -25 20, -23 10, -30 40))', 4326), 50),
   100,            -- width 
   100,            -- height
   ARRAY['8BUI'],  -- pixeltype
   ARRAY[118]      -- value
 ); -- using ST_AsRaster signature (geometry,int,int,text[],float[])

In this example you can use also the signature (geometry,int,int,text,float).

2
  • Copy/pasting that in gives the same error as OP was having.... Even copy/pasting the examples from the docs does. Sep 20, 2021 at 5:00
  • @DouglasGaskell check again, if fail again you must to chech version and installation. Jul 23, 2022 at 16:00

Your Answer

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

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