[postgis-users] How compute the stats from a raster table.

Andrea Peri aperi2007 at gmail.com
Fri Mar 16 02:38:41 PDT 2012


>SELECT (ST_SummaryStats(..)).* FROM ...
>
>Should show you "labels" to better understand.


Yes, thx, now it report me this:

 count | sum | mean | stddev | min | max
-------+-----+------+--------+-----+-----
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
 10000 |   0 |    0 |      0 |   0 |   0
.....

>I guess you could run aggregates on the single columns of the stats, like:
>
>WITH stats AS ( SELECT (ST_SummaryStats(..)).* FROM ... )
>SELECT sum(count) as count, sum(sum) ... FROM stats;

Thx , strk.

Running this query

WITH stats AS (
  SELECT
    (ST_SummaryStats(rast)).*
  FROM
    my_schema.my_table
)
SELECT
  sum(count) as count,
  sum(sum) as sum,
  avg(mean) as mean,
  avg(stddev) as stddev,
  min(min) as min,
  max(max) as max
FROM
 stats
;

I have the report I need.

   count   |    sum    |       mean       |      stddev      | min | max
-----------+-----------+------------------+------------------+-----+-----
 164020000 | 620088072 | 3.78056378490428 | 2.01499851432122 |   0 | 245
(1 riga)

>I guess it could be useful to define an aggregate taking
>"SummaryStats" type in input so you could do something like:
>
>SELECT (ST_SummaryStatsAgg(ST_SummaryStats(xx))).* FROM myrast;

I guess it should better.

-- 
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120316/78c3474e/attachment.html>


More information about the postgis-users mailing list