I am trying to find a solution to do the function of the QGIS-tool 'Generate points(pixel centroids) inside polygons' in PostGIS.
In the picture below you can see the output. Is there a way to do it in PostGIS?
Returns the centroid (point geometry) for each pixel of a raster band along with the value, the X and the Y raster coordinates of each pixel.
create table centroids as( SELECT x, y, val, ST_AsText(geom), geom FROM (SELECT dp.* FROM someraster, LATERAL ST_PixelAsCentroids(rast, 1) AS dp) foo join somepolygon on st_intersects(foo.geom, somepolygon.wkb_geometry) where somepolygon.id=328045)