I am trying to update a raster value in a postgres database with a postgis raster table using generate_series
I can access the entire table by doing
select st_value(rast,1,x,y),x,y from foo,generate_series(1,2,1) as x ,generate_series(1,3,1) as y
Which lists the entire table, the values of x and y been in the range 1-2 and 1-3 as expected.
I try to update it as follows
update foo set rast= st_setvalue(rast,1,q.x,q.y,200) from ( select x,y from generate_series(1,2,1) as x , generate_series(1,3,1) as y ) as q;
All that happens is the element at 1,1 gets updated, given the way the generate_series worked in the 1st quote I had expected this to work. I don't understand why not. I assume that the update statement is only using the first value of the generate_series function. But from the behaviour in the first example, I expected it work.
Reading around a common suggest is to use a Common Table Expressions, so I tried
with x as (select x from generate_series(1,2,1) as x), y as (select y from generate_series(1,3,1) as y) update foo set rast= st_values(rast,1,x,y,42);
This comes back with error claiming that column x does not exist
The table is defined as
rid | integer | | not null | nextval('foo_rid_seq'::regclass)
rast | raster | | |