[postgis-users] Contours of rasters without or with tiles

Mathieu Basille basille at ase-research.org
Tue Nov 27 15:26:31 PST 2012

OK, I found some sense out of this... Of course, ST_Union has to be called 
directly on the raster *before* ST_Envelope or ST_Polygon... Something like:

SELECT ST_Dump(ST_Envelope(ST_Union(rast))) FROM test.raster_tile;
(1 line)

However, I wonder whether ST_Envelope/Polygon should not do it 
automagically... It can be rather heavy on large raster files, though.


Le 27/11/2012 16:33, Mathieu Basille a écrit :
> Dear Hugues,
> I see now what you mean. ST_Envelope gives the behaviour you described
> (i.e. one polygon per tile, which is 9 lines). If I try to ST_Union them, I
> get the exact same problem I had before with ST_Polygon: not all
> polygon-tiles are unioned, as can be seen with a ST_Dump:
> SELECT ST_Dump(ST_Union(ST_Envelope(rast))) FROM test.raster_tile;
>                                           st_dump
> --------------------------------------------------
>   ({1},0103000020E6100000010000000900000024068...
>   ({2},0103000020E6100000010000000B0000009F1A2...
> (2 lines)
> With this line of code on the tile version of the raster, one would expect
> a single line as output (as is the case on the non-tiled raster).
> So my questions are really now:
> 1) Is this a desirable feature that vector functions such as ST_Envelope or
> ST_Polygon behave differently on tiled and non-tiled rasters? From my point
> of view, it shouldn't be the case, as the decision to tile a raster should
> be transparent from a user point of view (it's just a trick to get better
> performance for most GIS procedures). The same code should run fine on both
> types of rasters in my opinion.
> 2) How can we circumvent this "feature"? Using ST_Union should do it, but
> it's obviously not working as expected (at least by me).
> I feel like I'm getting quite far from my initial request, so maybe it
> should be better to start a new thread... Any opinion?
> Best,
> Mathieu.
> Le 27/11/2012 01:43, Francois Hugues a écrit :
>> Hello,
>> There's no mess ! You used my firstname correctly and I thank you for that.
>> To (try to) answer your questions :
>> 1. I would have use st_envelope to see what was the result and if the
>> problem would comes from no data values. St_envelope will also give you
>> one polygon by tile and the result will be totally different if you use
>> it with a tiled or non tiled raster.
>> 2. As st_envelope, I think the correct behaviour of st_polygon is to
>> proceed tile by tile if you tiled your raster (a tile by row = a polygon
>> by row).
>> Hugues.


~$ whoami
Mathieu Basille, PhD

~$ locate --details
University of Florida \\
Fort Lauderdale Research and Education Center
(+1) 954-577-6314

~$ fortune
« Le tout est de tout dire, et je manque de mots
Et je manque de temps, et je manque d'audace. »
  -- Paul Éluard

More information about the postgis-users mailing list