[postgis-users] ST_Mapalgebraexpr requires same alignment

Jose Carlos Martinez jomarlla at cgf.upv.es
Fri Mar 23 08:16:10 PDT 2012

On 23/03/2012 15:59, Pierre Racine wrote:
>> I though same alignment was not required because the docs said the alignment
>> is chosen from first raster, then I guessed the second raster could have different
>> alignment. I guessed it can support different alignment because otherwise I
>> think its very limited, maybe Im doing something wrong though but the normal
>> scenario its to make spatial analysis with raster which have different alignment.
> I agree that the doc is not that clear. I took a note.
>> How can I rewrite the sentence with raster which have different alignment? or I
>> should re-sample the whole raster to make them to have the same alignment?
>> insert into demdif (rast) select st_mapalgebraexpr (d1.rast, 1, st_union (d2.rast),
>> 1, 'abs([rast1.val] - [rast2-val])','16BSI', 'FIRST', null,
>> null,null) from dem200 d1, dem d2 where d1.rast&&  d2.rast and st_relate
>> (d1.rast::geometry, d2.rast::geometry, 'T********') group by d1.rid;
> I understand that they are in the same SRID but not aligned. This is two different things.
Yes they have same SRID
> It all depends if your raster table is tiled or not. If it's not tiled just ST_Resample(rast, ref) before passing to ST_MapAlgebra(). If it is tiled, resampling generate much overlapping nodata values. PostGIS Raster normally deal well with that but it generates much useless nodata value processing. I would suggest to merge outside, resample/reproject with GDAL and reload tiled.
The raster tables are all tiled.
Im wondering why st_mapalgebra can not work with no alignment rasters, 
maybe because it is working with pixel coordinates instead of terrain 
coordinates?..probably im wrong its just a guess. If the user makes sure 
the rast2 is covering completely rast1 I dont understand why it needs 
same alignment.
ummm...there is some plans about future releases to work with not 
alignment rasters? to be honest I think this is a limitation in order to 
to carry out a normal raster spatial analysis. :-(. I will try to use 
postgis raster without this feature though.

thanks Pierre
> Pierre
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

More information about the postgis-users mailing list