[postgis-users] Queries and (helper) functions for viewing and analysing PostGIS Raster data?

Paragon Corporation lr at pcorp.us
Thu Nov 25 10:04:27 PST 2010


ST_DumpAsPolygon and ST_Intersection  should be faster than pixel as
polygons for most use cases since ST_PixelAsPolygons basically converts each
pixel into the representative rectangular polygon and
ST_DumpAsPolygon/ST_Intersection does internal grouping  much of it in C
code to form polygons from same pixel values or just intersecting areas

Unfortunately there aren't any functions right now that would generate a
raster directly from raster to raster or raster 2 polygon operations - those
are still in the works with the ST_Band, ST_MapAlgebra functions which are
being developed right now and hopefully will be ready before PostGIS 2.0 is

FWIW - our newer version of PostGIS Raster chapter (not yet on MEAP) covers
ST_Intersection/ST_DumpAsPolygons in more depth and demonstrate how to
create rasters from scratch using existing rasters.  But  creating rasters
right now requires  ST_SetValue functions to do it.

As far as outputting rasters as rasters, I think GDAL suite is the only tool
that supports outputting PostGIS rsters as rasters at the moment.

Regina and Leo,

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Stefan
Sent: Thursday, November 25, 2010 12:25 PM
To: PostGIS Users Discussion
Subject: [postgis-users] Queries and (helper) functions for viewing and
analysing PostGIS Raster data?

I'm still trying to understand PostGIS Raster especially regarding analysis
and viewing PostGIS raster data. Let's begin with the latter.

=> What are the pros & cons to do this (and which is preferred?):
ST_DumpAsPolygons or ST_PixelAsPolygons?

Here is an example for viewing PostGIS Raster e.g. in OpenJUMP I found in
the Tutorial
(http://trac.osgeo.org/postgis/wiki/WKTRasterTutorial01 )

FROM srtm_tiled
WHERE rid=3278;

This seems to polygonize raster to vector. Unfortunately it's not explained
in the tutorial what the constraint clause "rid=3278" means:
it's obviously a single, distinct tile(?). From the book "PostGIS in
Action": "ST_DumpAsPolygons returns a set of single polygon, pixvalue pairs
for a given raster band and relies on the GDAL library. In many cases this
function will be easier and faster to use than going down to the level of
the pixel using ST_Value.". A solution for doing this I found here as a
pl/pgsql function called ST_PixelAsPolygons

Analysis: Regarding analysis I'd like to begin with the observation, that
all examples I've found so far are polygonizing rasters to vector. From the
tutorial doing overlay:

CREATE TABLE caribou_srtm_inter AS
  (ST_Intersection(rast, the_geom)).geom AS the_geom,
  (ST_Intersection(rast, the_geom)).val
FROM cariboupoint_buffers_wgs,
WHERE ST_Intersects(rast, the_geom);

=> What is the intended exact result type of this overlay operation query
(ST_Intersects)? POINT?
=> Which query would generate another raster layer (instead of a point
vector like in the above example)?

Yours, S.
postgis-users mailing list
postgis-users at postgis.refractions.net

More information about the postgis-users mailing list