[postgis-users] Dynamic parameters to ST_MapAlgebra

Guillaume Drolet droletguillaume at gmail.com
Thu Dec 11 07:14:14 PST 2014


Hi Regina,

"
Paragon Corporation-2 wrote
> Guillaume,
> 
> If the expression approach is faster, is there some reason you aren't just
> doing
> 
> 
>     WITH scaling_params AS (
>         SELECT gain::text As gain, off_set::text as off_set
>         FROM meta
>         WHERE product = 'MCD12Q2' AND sds = 'EVI'
>     )
>     SELECT ST_MapAlgebra(rast, 1, '32BF', '([rast] * ' || gain || ') + '
> ||
> off_set ) AS rast
>     FROM evi, scaling_params;
> 
> Or is that too hard-coded for you?

No it isn't. My SQL skills are just not enough sharp yet. I can't say I have 
loads of experience with this language and some of the possibilities still
slip 
my mind. Thanks for the enlightening me!

> Now regarding the one that Hugues gave you, you have to run it differently
> from how you were calling your others, otherwise it would take forever
> since
> for every raster row you have it would apply map algebra to all the rows
> in
> your table.  So how did you call his?

Called it pretty much the same way as I showed in my first post: 

    SELECT scale_sds_plpgsql(rast, 0.01, 0.0)
    FROM evi
    WHERE date = mydate;

> If you wanted to use the syntax you have I would rewrite your plpgsql as
> follows (and not use dynamic sql) - you don't need dynamic sql to do this
> just call ST_MapAlgebra directly.

When I referred to 'dynamic', I meant with passing parameters resulting from
a query. Maybe 'dynamic' isn't the right word?

Thanks for all your suggestions, I appreciate it. Will try them and see how
they improve things.

Best wishes,

G















--
View this message in context: http://postgis.17.x6.nabble.com/Dynamic-parameters-to-ST-MapAlgebra-tp5007468p5007475.html
Sent from the PostGIS - User mailing list archive at Nabble.com.


More information about the postgis-users mailing list