How to deal with rpg2pgsql bitmap tiles?

I imported a bitmap file to PostGIS using raster2pgsql, I set -t 50x50 and created about 500 lines. I know that these -t divides the raster into small tiles and they can index them. I've seen many examples using rid = 2 in the where clause to specify the tile. But my question is how to handle the whole bitmap and not a specific chunk. For example, when I use ST_SummaryStats, it generates statistics of 500 row results for each chunk. When I ST_Clip it also generates about 500 rows of clipping results for each chunk. How do I clip the entire raster? Thank!!

+3


source to share


1 answer


I think ST_Union

this is what you are looking for. First you need to merge all the tiles and then apply your work.

Usage example ST_SummaryStats

.

db=# SELECT ST_SummaryStats(rast) FROM t;
               st_summarystats               
---------------------------------------------
 (100,24638,246.38,14.0176888251951,216,255)
 (100,23866,238.66,16.7488626479531,216,255)
 (100,22052,220.52,3.85092196752934,218,235)
 (100,22495,224.95,10.0173599316387,216,255)
 (100,22508,225.08,8.46720733181846,216,255)
 (100,22034,220.34,2.08911464501113,218,228)
 (100,22113,221.13,2.26121648676105,219,228)
 (100,22172,221.72,2.24089267926869,218,228)
 (100,22163,221.63,2.11969337405201,219,228)
 (100,22332,223.32,2.42024792118494,219,227)
(10 Zeilen)

      

Now this same operation using ST_Union

:



db=# SELECT ST_SummaryStats(ST_Union(rast)) FROM t;
                st_summarystats                 
------------------------------------------------
 (1000,226373,226.373,11.8122762835958,216,255)
(1 Zeile)

      

For summary statistics, you can also use ST_SummaryStatsAgg

:

db=# SELECT ST_SummaryStatsAgg(rast,1,false) FROM t;
               st_summarystatsagg               
------------------------------------------------
 (1000,226373,226.373,11.8122762835958,216,255)
(1 Zeile)

      

0


source







All Articles