4
votes

I have raster table in postgresql that I create it using PostGIS raster. If I want to have average raster of 3 raster records considering that the Null pixel values shouldn't be involved in the averaging operation. I mean that pixel values of the resulting raster record should be mean value of the corresponding pixel values of the 3 existing raster records. The raster records contain some pixels with Null values and the Null values should not be involved in the computation. Is it possible? the sample_data_link is the link for sample data which are images. If Postgis 2.0 is installed in your system the following commands in commandline of windows and for the folder you copied the sample data will create the results:
raster2pgsql -r *_cropped.tif -F -I myschema.mytable > cropped_1.sql and
raster2pgsql -r *_cropped.tif -F -I myschema.mytable > cropped_1.sql

2
what do you mean by sample data? what is it for?f.ashouri
You're going to get more interest in answering your question by making it easier to answer. Say, by providing the SQL CREATE TABLE and INSERT commands to set up a minimal subset of your environment. That way anyone who's interested doesn't have to spend the time creating dummy data to test possible solutions.Craig Ringer
I added the sample data how to insert it. But you need to have postgis 2.0 to make it work.f.ashouri

2 Answers

2
votes

you can turn it to an array and do the computation on it and then convert the array to the raster.

1
votes

The documentation on ST_Union references some code in the postgis source that implements various functions in plpgsql.

You could take one of these as a base and modify it to ignore null pixels. Line 253 looks promising. (Note: the resulting code would be GPL-licensed).