SQL: Union of polygons

后端 未结 4 1312
一向
一向 2021-01-06 07:36

I have a table with a single column of geometry type, containing polygons. How do I get the union of all the polygons in the table?

4条回答
  •  长情又很酷
    2021-01-06 08:05

    In SQL Server 2012:

    SELECT geometry::UnionAggregate(geomcolumn) FROM YourTable;
    

    In SQL Server 2008/R2:

    DECLARE @g = geometry::STGeomFromText('GEOMETRYCOLLECTION EMPTY', YourSRID);
    SELECT @g = @g.STUnion(geomcolum) FROM YourTable;
    

提交回复
热议问题