[postgis-users] select raster by pixel value

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Fri Oct 16 07:41:57 PDT 2015

First try on using raster in postgis 2.1. I used raster2pgsl to load a 

Then I want to select the rids where pixel value = 9
I ended up with this query
SELECT a.rid,(pvc).value

from test as a

join (SELECT rid,ST_ValueCount(rast) As pvc FROM test) as b ON b.rid = 
a.rid and (pvc).value = 9

order by a.rid;

This select returns 28517 records

But using this SQL to get the distinct count i get 1055421
 records for pixel value 9
SELECT (pvc).value, SUM((pvc).count) As total

 FROM (SELECT ST_ValueCount(rast) As pvc

   FROM test) As f

    GROUP BY (pvc).value 
order by value;

Obviously there is something I do wrong...
What is it I don't understand?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20151016/28bf8ee2/attachment.html>

More information about the postgis-users mailing list