[postgis-devel] [PostGIS] #1639: [raster] MapAlgebraExpr can't handle conditions
PostGIS
trac at osgeo.org
Thu Mar 1 14:58:10 PST 2012
#1639: [raster] MapAlgebraExpr can't handle conditions
---------------------+------------------------------------------------------
Reporter: nicklas | Owner: pracine
Type: defect | Status: new
Priority: high | Milestone: PostGIS 2.0.0
Component: raster | Version: trunk
Keywords: |
---------------------+------------------------------------------------------
Comment(by dustymugs):
The following works for me using your expression...
{{{
DROP TABLE IF EXISTS test_mapalgebra;
CREATE TABLE test_mapalgebra(
rid serial PRIMARY KEY,
rast raster
);
CREATE OR REPLACE FUNCTION make_test_raster()
RETURNS void
AS $$
DECLARE
width int := 5;
height int := 5;
x int;
y int;
rast raster;
BEGIN
rast := ST_MakeEmptyRaster(width, height, 0, 0, 1, -1, 0,
0);
rast := ST_AddBand(rast, 1, '8BUI', 0, 0);
FOR x IN 1..width LOOP
FOR y IN 1..height LOOP
rast := ST_SetValue(rast, 1, x, y,
random() * 256);
END LOOP;
END LOOP;
INSERT INTO test_mapalgebra (rast) VALUES (rast);
RETURN;
END;
$$ LANGUAGE 'plpgsql';
SELECT make_test_raster();
SELECT make_test_raster();
DROP FUNCTION make_test_raster();
WITH foo AS (
SELECT
ST_MapAlgebraExpr(a.rast, b.rast, '(([rast1]-[rast2]) >
50)::int', '1BB') AS rast
FROM test_mapalgebra a
CROSS JOIN test_mapalgebra b
WHERE a.rid = 1
AND b.rid = 2
)
SELECT
(ST_BandMetadata(rast)).*,
(ST_SummaryStats(rast)).*
FROM foo;
DROP TABLE IF EXISTS test_mapalgebra;
}}}
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1639#comment:7>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-devel
mailing list