I am trying to do something very similar, I found an item at
[fast contour lines using plain postgis1. it creates a contour map from your list of points. I get the impression it expects rectangle input.
My problem with this solution was the calling method, it uses array of data, a concept which is outside of most sql grammers.
My data weather point data, where geom the point location, speed a scalar value denoting the current wind speed and reading_time the value data was collected.
My calling code is
drop table foo;
create table foo(
id serial,
geom geometry ,
break numeric
);
insert into foo (geom,break )
select
(contour_lines( array_agg(geom),array_agg(speed::numeric),
ARRAY[ 0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5,12.0,12.5,13.0,13.5,14.0,14.5,15.0,15.5,16.0,16.5] )).geom ,
(contour_lines( array_agg(geom),array_agg(speed::numeric),
ARRAY[ 0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5,12.0,12.5,13.0,13.5,14.0,14.5,15.0,15.5,16.0,16.5] )).break
from windproc where reading_time='2018-08-28 07:00:00+01' and geom is not null and speed is not null;
Where array_agg creates an array of the object supply as an argument. The array construct creates a list of step/break values which is used a banding values for the generated contour lines.
The code for contour_lines is provided by the link. it expects a numeric value for scalar value (in my case speed) hence the cast.
The reason there is what appears to be a double called to contour_lines is that you need to get the break and geom answers provide by contour_lines function, but since array_agg is an aggrate function it can only appear in some parts of sql construct.
The result from this will give you a table called foo with the desired information in the geom column