[postgis-devel] ST_MapAlgebra (was: ST_Value performance)

Sandro Santilli strk at keybit.net
Tue Jan 31 14:19:49 PST 2012


On Tue, Jan 31, 2012 at 10:53:27PM +0100, Sandro Santilli wrote:
> On Tue, Jan 31, 2012 at 08:39:27PM +0100, Sandro Santilli wrote:
> > On Tue, Jan 31, 2012 at 02:07:31PM -0500, Pierre Racine wrote:
> > > Could you tell us more about your general goal. Seems to be a case for ST_MapAlgebra...
> > 
> > Yes, indeed I should be using ST_MapAlgebra.
> 
> So, for the record, the expression I would be using in ST_MapAlgebra
> could be this:
> 
> -- shift_lon (band 1)
> (
>  st_x(st_centroid(rast)) -
>  st_x(
>    st_transform(postgis_transform_geometry(st_centroid(rast), '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +units=m +nadgrids=CHENYX06a.gsb +no_defs', '+init=epsg:4326', 4150), 4326)
> ))*3600
> 
> 
> -- shift_lat (band 2)
> (
>  st_y(
>    st_transform(postgis_transform_geometry(st_centroid(rast), '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +units=m +nadgrids=CHENYX06a.gsb +no_defs', '+init=epsg:4326', 4150), 4326)
>  ) - st_y(st_centroid(rast))
> )*3600
> 
> I've used "rast" for references into the raster itself.
> You can see the expression contains a few single quotes.
> Haven't tried it.

Now I tried it and realized that "rast" in the expression refers to the
pixel value while I don't care about that. 
Instead, I need the _position_ of the pixel.
That is, my expression is a function of the pixel position, not of its
value.

Would it make sense to then provide that information as well as a
placeholder, in addition to the value ?

BTW, "rast" is somewhat misleading as the name of a placeholder for the
raster value...

--strk; 

  ,------o-. 
  |   __/  |    Thank you for PostGIS-2.0 Topology !
  |  / 2.0 |    http://www.pledgebank.com/postgistopology
  `-o------'




More information about the postgis-devel mailing list