[postgis-devel] Regular expressions in PostGIS sources

Jorge Arévalo jorge.arevalo at deimos-space.com
Mon Nov 15 15:06:58 PST 2010


On Mon, Nov 15, 2010 at 9:40 PM, Paul Ramsey <pramsey at opengeo.org> wrote:
> Could you give me some richer examples of the syntax in the form of
> full SQL statements?
>

Yes, of course. From current documentation: "The expression is any
PostgreSQL valid expression returning a number. This expression can
contain conditional expressions like CASE or any user-defined
function. In the one raster version of ST_MapAlgebra, the value of the
current pixel is expressed in the expression by "rast". E.g.
'cos(rast)' or 'rast / 2'"

The calls to the MapAlgebra function will follow the syntax:

ST_MapAlgebra(rast raster, band integer, expression text,
nodatavalueexpr text, pixeltype text)

And the expressions will be something like 'rast + 20', 'rast / 2',
'cos(rast)', '2*rast + 3/rast', '5', etc. Then, each pixel of the
raster must be used in that operation, by replacing the word 'rast'
for its value, and storing the resulting pixel value in the output
raster. It's a basic MapAlgebra implementation, with only one raster,
by now.

You have a PL/pgSQL implementation at
http://svn.osgeo.org/postgis/trunk/raster/scripts/plpgsql/st_mapalgebra.sql

But we're working on a C implementation

> 2010/11/15 Jorge Arévalo <jorge.arevalo at deimos-space.com>:
>> On Mon, Nov 15, 2010 at 7:19 PM, Paul Ramsey <pramsey at opengeo.org> wrote:
>>> There's some regex support in postgresql core. What do you need regex
>>> for in raster?
>>>
>>> P
>>
>> Hi Paul,
>>
>> For MapAlgebra implementation at core level. The ST_MapAlgebra
>> Pl/pgSQL function takes an input argument like "SELECT rast + 3",
>> meaning "add 3 to all raster's pixels", and it calls a  core function
>> (via postgresql function) to perform the operation.
>>
>> Should I parse the expression in PL/pgSQL function, at postgresql
>> level or at core level? Now, I'm working only at core level.
>>
>> Thanks!
>>
>> --
>> Jorge Arévalo
>> Internet & Mobilty Division, DEIMOS
>> jorge.arevalo at deimos-space.com
>> http://mobility.grupodeimos.com/
>> http://gis4free.wordpress.com
>>
>>
>>>
>>> 2010/11/15 Jorge Arévalo <jorge.arevalo at deimos-space.com>:
>>>> Hi all,
>>>>
>>>> Is there any mechanism in PostGIS to deal with regular expressions and
>>>> string replacement at core level (I mean, C functions)? I'm going to
>>>> use string replacement in PostGIS Raster but I don't want to reinvent
>>>> the wheel, if is invented
>>>>
>>>> Many thanks in advance,
>>>>
>>>> --
>>>> Jorge Arévalo
>>>> Internet & Mobilty Division, DEIMOS
>>>> jorge.arevalo at deimos-space.com
>>>> http://mobility.grupodeimos.com/
>>>> http://gis4free.wordpress.com
>>>> _______________________________________________
>>>> postgis-devel mailing list
>>>> postgis-devel at postgis.refractions.net
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>>>
>>> _______________________________________________
>>> postgis-devel mailing list
>>> postgis-devel at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>>
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>



-- 
Jorge Arévalo
Internet & Mobilty Division, DEIMOS
jorge.arevalo at deimos-space.com
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com



More information about the postgis-devel mailing list