[postgis-devel] WKTRaster ST_MapAlgebra

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Sun Feb 21 11:52:24 PST 2010


>>>That sounds like you would want ST_MapAlgebra to look like:
>>>
>>>1- ST_MapAlgebra(rastergrid|geometry, [rastergrid|geometry,...],
>>>'mathematical expression', 'rastergrid' |'geometry') ->
>>>rastergrid/geometry
>>>
>>>where the 1st 'rastergrid' was the master, or:
>>>
>>>2- ST_MapAlgebra(raster|geometry, [raster|geometry,...], 'mathematical
>>>expression', 'raster' |'geometry', originx, originy, pixelsizex,
>>>pixelsizey) -> raster/geometry
>>
>> Sounds good! (I assume that rastergrid in the first one is actually a raster)
>
>I wasn't thinking rastergrid would be a raster, I was borrowing from
>your idea where you mentioned: "We could also create a RasterGrid kind
>of object carrying those four parameters."  So the first method would
>be carrying all the position and size parameters inside this
>RasterGrid object, 

Including the raster itself? Where is the raster? A raster grid object would only carry the parameters describing a grid, no raster data. The function works on a raster object. It must be there. That was my variant 4 in the previous mail (where the first parameter should have been raster, not rastergrid by the way. My mistake. Idem in variant 3).


>Although, as I think about it more, this RasterGrid is redundant --
>aren't all the position, size, and alignment parameters inside of
>Raster already?  In that case, then rastergrid is synonymous with
>raster, and I didn't fully understand what you meant when you
>mentioned creating a RasterGrid object.

The idea is simply to compact the 4 parameterz describing a rastergrid into one parameter a bit like what Regina sugested about rasterband in a previous thread. A rastergrid does not carry raster data. You must then also include the raster in a function having rastergrid as parameter.

Yes, the position, size, and alignment parameters are in every raster object. They are the georeference of the raster. There is a difference between setting a new georeference (ST_SetGeoReference() where you just move and/or scale the raster without touching the data itself) and changing its grid alignment (ST_Resample() where you certainly don't want to move the raster but just resample it so it fits a new grid alignment and/or raster size). SetGeoreference is trivial to implement, ST_Resample is not.

>On a side note, I was looking into the MapAlgebra operations on two
>rasters in the same CS, but with different rotations:  the cell size
>of the resulting raster (by default) is the smallest cell at 0
>rotation that would encapsulate a rotated cell.  In my experiment, I
>rotated a raster 45 degrees and did a simple add (A+B).  The input
>cell size was 1, and the output cell size was ~1.4, or sqrt(2).

By the way, a rastergrid object should probably also include two rotation parameters. A grid can be rotated...

I promise to look carefully at your working spec monday morning.

Pierre


More information about the postgis-devel mailing list