3

I'm trying to calculate a NDVI index for a raster of Landsat TM with ST_MapAlgebraExpr in PostGIS (2.1):

CREATE TABLE ndvi_lugo_tm AS (
SELECT
ST_MapAlgebraExpr(lugo_tm.rast, 5, lugo_tm.rast, 4, 
(('[rast1.val]-[rast2.val])/[rast1.val]+[rast2.val]+0.01')),
'32BF', 'INTERSECTION') 
AS rast, 1 AS rid
FROM lugo_tm AS lugo_tm);

But I get error:

ERROR: error de sintaxis en o cerca de «)» LINE 1: SELECT ($1-$2)/$1+$2+0.01)::double precision ^ QUERY: SELECT ($1-$2)/$1+$2+0.01)::double precision ********** Error ********** ERROR: error de sintaxis en o cerca de «)»

Can anyone help me?

0

Some of your brackets are misplaced:

('[rast1.val]-[rast2.val])/[rast1.val]+[rast2.val]+0.01' : in that expression you have a closing bracket at -[rast2.val]) that match no opening bracket.

Secondly: Why do you have consecutive brackets there. You shouldn't, thought that won't be breaking anything (('[rast1.val]-[rast2.val])/[rast1.val]+[rast2.val]+0.01'))

Good luck

Fabien

  • Thank you Fabien....One of the parentheses was not necessary... – AR Diego Jan 27 '17 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.