[postgis-users] Split polygon by line

Sandro Santilli strk at kbt.io
Thu Oct 18 07:51:35 PDT 2018


On Thu, Oct 18, 2018 at 04:38:53PM +0200, Sandro Santilli wrote:

> I guess QGIS wants to know the exact geometry type of the layer,
> which you could specify with a cast:
> 
>     SELECT ST_Split(circle, line)::geometry(polygon)

Sorry, I was too quick at answering. ST_Split returns a
GEOMETRYCOLLECTION, not a polygon (split creates multiple polys)
so you want to ST_Dump them, for example:

  SELECT geom FROM ST_Dump(
    ST_Split(
      ST_Buffer('POINT(0 0)'::geometry, 10),
      'LINESTRING(-20 5, 20 5)'
    )
  );

--strk;


More information about the postgis-users mailing list