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

Francois Hugues hugues.francois at irstea.fr
Mon Nov 26 09:02:22 PST 2012


Hello,

Did you try with the bounding boxes of your tiles using st_envelope ? I operated numerous tiles and unioned them with this function.

Your picture does not show us how many lines your last query returns. Here, it could be a multipolygon.

Hugues.

 

-----Message d'origine-----
De : postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] De la part de Mathieu Basille
Envoyé : vendredi 23 novembre 2012 21:53
À : PostGIS-users
Objet : [postgis-users] Contours of rasters without or with tiles

Dear PostGIS users,

Here is a simple case: I'd like to extract the contour polygon of a given raster. The dedicated function should be ST_Polygon. If I run it on the raster imported without tiles, I get one polygon per island/continent, which is exactly what I want. However, if the raster uses tiles, I get one polygon per island/continent for each tile (which makes sense). I could merge them using ST_Union, but I was unable to do that completely: some polygons do get merged, but not all. This can be fairly problematic in my case, since I'm using buffers of the resulting polygon, which means I need one polygon per island/continent.

Example case, with the simple raster attached:

Importation without tiles:

raster2pgsql -s 4326 -I -C -M raster.tif test.raster | psql -h localhost -d database -U pguser

Importation with tiles:

raster2pgsql -s 4326 -t 5x5 -I -C -M raster.tif test.raster_tile | psql -h localhost -d database -U pguser

Using ST_Polygon:

CREATE TABLE test.pol AS
SELECT ST_Polygon(rast) FROM test.raster;

CREATE TABLE test.pol_t AS
SELECT ST_Polygon(rast) FROM test.raster_tile;

Using ST_Union on the result:

CREATE TABLE test.pol_tu AS
SELECT ST_Union(ST_Polygon(rast)) FROM test.raster_tile;

See the picture attached to see the result. 'pol' and 'pol_t' give the expected results, but not 'pol_tu'. Is this an expected behaviour? Is there a workaround to this problem?

Thanks in advance for any hint!
Mathieu.


# SELECT PostGIS_Full_Version();
 
     postgis_full_version 

-----------------------------------------------------------------------
  POSTGIS="2.1.0SVN r10597" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 2.0dev, released 2011/12/29" LIBXML="2.8.0" 
LIBJSON="UNKNOWN" TOPOLOGY RASTER


-- 

~$ whoami
Mathieu Basille, PhD

~$ locate --details
University of Florida \\
Fort Lauderdale Research and Education Center
(+1) 954-577-6314
http://ase-research.org/basille

~$ 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