id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
1336,[raster] Problem with ST_AsRaster() alignment,pracine,pracine,"I have a test raster that I display in Openjump:

{{{
CREATE OR REPLACE FUNCTION ST_TestRaster(h integer, w integer, val float8) 
    RETURNS raster AS 
    $$
    DECLARE
    BEGIN
        RETURN ST_AddBand(ST_MakeEmptyRaster(h, w, 0, 0, 1, 1, 0, 0, 0), '32BF', val, -1);
    END;
    $$
    LANGUAGE 'plpgsql';

SELECT ST_AsBinary((ST_PixelAsPolygons(ST_TestRaster(10, 10, 2))).geom);
}}}

Then I have a simple overlapping geometry:

{{{
SELECT ST_AsBinary(ST_Buffer(ST_MakePoint(8, 5), 4));
}}}

If I convert it to a raster aligned on the first raster I get:

{{{
SELECT ST_AsBinary((gv).geom), (gv).val 
FROM ST_PixelAsPolygons(ST_AsRaster(ST_Buffer(ST_MakePoint(8, 5), 4), 
                                    ST_TestRaster(10, 10, 2), 
                                    ST_BandPixelType(ST_TestRaster(10, 10, 2), 1), 
                                    1, 
                                    -10
                                   )
                        ) gv
}}}

The two rasters are well aligned. However if I try:

{{{
SELECT ST_MapAlgebraExpr(ST_TestRaster(10, 10, 2), 1, 
                         ST_AsRaster(ST_Buffer(ST_MakePoint(8, 5), 4), 
                                     ST_TestRaster(10, 10, 2), 
                                     ST_BandPixelType(ST_TestRaster(10, 10, 2), 1), 
                                     1, 
                                     -10
                                    ), 1, 
                         'rast1')
}}}

I get ""NOTICE:  The two rasters provided do not have the same alignment.  Returning NULL""...

If I just replace the rasterized geometry with the original raster like this:

{{{
SELECT ST_MapAlgebraExpr(ST_TestRaster(10, 10, 2), 1, 
                         ST_TestRaster(10, 10, 2), 1, 
                         'rast1')
}}}

there is no problem...

I am trying to implement ST_Clip()...",defect,closed,medium,PostGIS 2.0.0,raster,trunk,fixed,,
