Average raster record from other raster records in PostGIS Raster

I have a raster table in postgresql that I create using a PostGIS raster. If I want to have an average raster file of 3 raster records, given that Null pixel values โ€‹โ€‹should not be involved in the averaging operation. I mean, the pixel values โ€‹โ€‹of the resulting raster record should be the average of the corresponding pixel values โ€‹โ€‹for the three existing raster records. Raster records contain some pixels with Null values, and Null values โ€‹โ€‹should not be involved in the calculation. Is it possible? sample_data_link is a link for sample data, which are images. If Postgis 2.0 is installed on your system, the following commands on the windows command line and the folder where you copied the sample data will produce the following results:
raster2pgsql -r *_cropped.tif -F -I myschema.mytable > cropped_1.sql and
raster2pgsql -r *_cropped.tif -F -I myschema.mytable > cropped_1.sql

+4
source share
2 answers

you can rotate it into an array and do the calculation on it, and then convert the array to a raster.

+2
source

documentation on links ST_Union some code in postgis that implements various functions in plpgsql.

You can take one of them as a base and change it to ignore zero pixels. Line 253 looks promising. (Note: the resulting code will be licensed by the GPL).

+1
source

Source: https://habr.com/ru/post/1445016/


All Articles