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

2012-03-17 Thread Andrea Peri
sorry , I lack to report the error message.

The error message was:

ERROR: relation my_schema.my_table does not exist

Please notice I'm using the postgres (dba) account in this executions..

The inquiry for the postgis version report:

POSTGIS=2.0.0beta2SVN r9389 GEOS=3.3.2-CAPI-1.7.2 PROJ=Rel. 4.7.1, 23
September 2009 GDAL=GDAL 1.9.0, released 2011/12/29 LIBXML=2.7.6

Now I update the postgis to last available trunk.

-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Andrea Peri
ST_SummaryStats()

Hi Pierre,

I try it ,
but i'm not sure to understand the results.

The docs say it return the stats for a given raster band of a raster coverage.
I assume this was mean It return me a single row of values for the raster table.
Instead It return me many records of type SummaryStats.

It seem to return a result for every table row.
I'm not soo skilled on the raster to well understand what is a row
table in a raster table.
I guess, perhaps, it is the tile ?
If yes, this mean it is returning the stats for every tile.

And so my quest now is how to retrieve the total stat for all the raster table.
Also I cannot try the group by because the ST_SummaryStats is not an
aggregate function.

This is the query I try:

select ST_SummaryStats(rast_column) from my_schema.my_table;

Thx,

-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Sandro Santilli
On Fri, Mar 16, 2012 at 08:17:14AM +0100, Andrea Peri wrote:
 ST_SummaryStats()
 
 Hi Pierre,
 
 I try it ,
 but i'm not sure to understand the results.

SELECT (ST_SummaryStats(..)).* FROM ...

Should show you labels to better understand.

 If yes, this mean it is returning the stats for every tile.
 
 And so my quest now is how to retrieve the total stat for all the raster 
 table.

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;

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;

--strk; 

  ,--o-. 
  |   __/  |Delivering high quality PostGIS 2.0 !
  |  / 2.0 |http://strk.keybit.net - http://vizzuality.com
  `-o--'

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Andrea Peri
SELECT (ST_SummaryStats(..)).* FROM ...

Should show you labels to better understand.


Yes, thx, now it report me this:

 count | sum | mean | stddev | min | max
---+-+--++-+-
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   0 |0 |  0 |   0 |   0
 1 |   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
---+---+--+--+-+-
 16402 | 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 àèìòù
-
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Pierre Racine
 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;

Try this:

http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_summarystatsagg.sql

...exactly like strk wrote it.

Pierre
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Sandro Santilli
On Fri, Mar 16, 2012 at 09:52:38AM -0400, Pierre Racine wrote:
  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;
 
 Try this:
 
 http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_summarystatsagg.sql
 
 ...exactly like strk wrote it.

BTW, reading the manual (incredibly, it helps!) I found out there's
a version of ST_SummaryStats that takes a table name.

Not flexible as the aggregate but for Andrea's case should do just fine.

--strk;

  ,--o-. 
  |   __/  |Delivering high quality PostGIS 2.0 !
  |  / 2.0 |http://strk.keybit.net - http://vizzuality.com
  `-o--'

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Andrea Peri
Hi strk,

I see it ,
but try-ing it I have an error:

this is the query I try:

select ST_SummaryStats('my_schema.my_table','rast', true);


-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-16 Thread Sandro Santilli
On Fri, Mar 16, 2012 at 09:27:42PM +0100, Andrea Peri wrote:
 Hi strk,
 
 I see it ,
 but try-ing it I have an error:
 
 this is the query I try:
 
 select ST_SummaryStats('my_schema.my_table','rast', true);

And the error says ?
And select postgis_full_version() ?

--strk;

  ,--o-. 
  |   __/  |Delivering high quality PostGIS 2.0 !
  |  / 2.0 |http://strk.keybit.net - http://vizzuality.com
  `-o--'

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-14 Thread Andrea Peri
Hi,

Try -ing to access with mapserver from a raster.table.
I will have some problems.
Now I discovered the problem was that mapserver try to compute the stats
from my postgis raster.table and this will cause a timeout.

So I like to set programmatically these stats.

To find these values I could use the gdalinfo , but if possible I like to
do this inside the postgis.
There is a function in postgis.raster api to compute the full stats of a
raster table ?

Thx,

-- 
-
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


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

2012-03-14 Thread Pierre Racine
ST_SummaryStats()

 -Original Message-
 From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users-
 boun...@postgis.refractions.net] On Behalf Of Andrea Peri
 Sent: Wednesday, March 14, 2012 7:27 PM
 To: PostGIS Users Discussion
 Subject: [postgis-users] How compute the stats from a raster table.
 
 Hi,
 
 Try -ing to access with mapserver from a raster.table.
 I will have some problems.
 Now I discovered the problem was that mapserver try to compute the stats from
 my postgis raster.table and this will cause a timeout.
 
 So I like to set programmatically these stats.
 
 To find these values I could use the gdalinfo , but if possible I like to do 
 this
 inside the postgis.
 There is a function in postgis.raster api to compute the full stats of a 
 raster table
 ?
 
 Thx,
 
 --
 -
 Andrea Peri
 . . . . . . . . .
 qwerty àèìòù
 -
 

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users