I have to find the count of the number of pixels in a given band of a clipped raster. For clipping, I am using ST_clip(). Through clip function raster is clipped with a polygon. I am getting following error

function st_clip(raster, integer, geometry) does not exist

I am not sure about the placements of the paranthesis.

SELECT ST_ValueCount(ST_Clip(rast,1,ST_Transform(ST_GeomFromText('POLYGON((76.36792879303643 13.633268921278498,77.64804272121083 13.625811445922459,77.58727436708882 12.839858067425443,76.54887536367008 12.766426303994999,76.36792879303643 13.633268921278498))',4326), 4326)),1,false) AS valuecount FROM raster_file;


Should I use ST_UNION before ST_clip as my raster file is tiled and then saved in postgis using 'raster2pgsql' command.

Otherwise please provide a proper example to clip a raster from polygon, and to find the valuecount.

closed as off-topic by user30184, John Powell, Mapperz Apr 10 '15 at 16:05

  • This question does not appear to be about geographic information systems (GIS) within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You have 4326 twice which may be part of the problem. – John Powell Apr 10 '15 at 12:09
  • @JohnBarça What could be the query for clipping raster with a polygon and then find the valuecount. I am still getting same error after removing ST_transform. – Padfoot Apr 10 '15 at 12:28
  • You need ST_SetSrid not ST_Transform. Sorry missed that. – John Powell Apr 10 '15 at 12:52
  • @JohnBarça, thanks for that. But my problem is improper placements of the paranthesis ( as I feels) because I am getting 'function st_clip(raster, integer, geometry) does not exist' as an error. And please check the question again as I have edited my issue. – Padfoot Apr 10 '15 at 12:58
  • 2
    I'm voting to close this question as off-topic because the problem does not have to do with GIS. It is only about writing SQL with right syntax. – user30184 Apr 10 '15 at 13:10