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

Mathieu Basille basille at ase-research.org
Fri Nov 23 12:53:17 PST 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pol.png
Type: image/png
Size: 2448 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121123/f4bc9406/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pol_t.png
Type: image/png
Size: 2764 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121123/f4bc9406/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pol_tu.png
Type: image/png
Size: 2484 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121123/f4bc9406/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raster.png
Type: image/png
Size: 2847 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121123/f4bc9406/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raster.tif
Type: image/tiff
Size: 904 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121123/f4bc9406/attachment.tif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raster.tif.aux.xml
Type: text/xml
Size: 401 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121123/f4bc9406/attachment.xml>


More information about the postgis-users mailing list