[postgis-users] Clipping a raster and a polygon using ST_Intersection

liglio.pessoal at nexxa.com.br liglio.pessoal at nexxa.com.br
Tue Nov 22 10:59:34 PST 2022


Hi,

 

I created a retangular raster representing number of lightnings in a square.
So I have this matrix raster created using ST_MapAlgebraFct and
ST_MakeEmptyRaster. 

This raster is not a tiled raster (tb_densitysurface), and when I Clip this
raster using a polygon, the query below, the performance is not good.

Maybe because the raster is not tiled. So how do I tile this raster ? And I
want the result to be a raster (not gval) to be exported as a file, and then
colored using GDAL.

It worked with a different query only using ST_Clip (this returns a rast
column and is very fast), but the edges aren´t smooth as using
ST_Insersection. I am using Postgis 2.5.

 

SELECT

    (gval).val

    (gval).geom

FROM (

    SELECT ST_Intersection(

        ST_Clip(rast,ST_Envelope(area_country)),

        1,

       area_country

    ) As gval

    FROM country, tb_densitysurface WHERE ST_Intersects(rast, area_country)
and country.gid = 19

) As foo

 

 

Regards,

 

Liglio

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20221122/70a24a6f/attachment.htm>


More information about the postgis-users mailing list