Union all geometry in a SQL Server table like GeomUnion in Postgres

后端 未结 3 1557
借酒劲吻你
借酒劲吻你 2021-01-11 13:14

Just to clarify up-front: I\'m talking about unioning geometry, not the SQL keyword UNION.

I\'m trying to move some spatial data from Postgres with Post

相关标签:
3条回答
  • 2021-01-11 13:59

    Your best option is to create a CLR function to support the aggregate. There are a couple of existing solutions:

    • Sql spatial tools
    • Spatail aggregate
    0 讨论(0)
  • 2021-01-11 14:01

    The way I ended up doing this is with variables:

    DECLARE @Shape GEOMETRY
    SET @Shape = GEOMETRY::STGeomFromText('GEOMETRYCOLLECTION EMPTY', @MySrid)
    
    SELECT @Shape = @Shape.STUnion(Shape)
      FROM MyShapeTable
    

    It's not as nice, but it works.

    0 讨论(0)
  • 2021-01-11 14:07

    Is the UnionAggregate function SQL2012 only?

    SELECT geography::UnionAggregate( geometry ) FROM some_table
    

    Hmm guess so. http://technet.microsoft.com/en-us/library/ff929095.aspx

    0 讨论(0)
提交回复
热议问题