Categorias:

Funções geospaciais

ST_UNION_AGG

Dada uma coluna GEOGRAPHY, retorna um objeto GEOGRAPHY que representa o conjunto combinado de pontos que estão em pelo menos uma das formas representadas pelos objetos na coluna (ou seja, a união das formas).

Consulte também:

ST_UNION , ST_INTERSECTION_AGG

Sintaxe

ST_UNION_AGG( <geography_column> )
Copy

Argumentos

geography_column

Uma coluna GEOGRAPHY.

Retornos

A função retorna um valor do tipo GEOGRAPHY.

Exemplos

Crie uma tabela com uma coluna GEOMETRY e insira dados:

CREATE OR REPLACE TABLE st_union_agg_demo_table (g GEOGRAPHY);

INSERT INTO st_union_agg_demo_table VALUES
  ('POINT(1 1)'),
  ('POINT(0 1)'),
  ('LINESTRING(0 0, 0 1)'),
  ('LINESTRING(0 0, 0 2)'),
  ('POLYGON((10 10, 11 11, 11 10, 10 10))'),
  ('POLYGON((10 10, 11 11, 11 10, 10 10))');
Copy

Use a função ST_UNION_AGG para retornar um objeto GEOGRAPHY que representa o conjunto combinado de pontos que estão em pelo menos uma das formas representadas pelos objetos na coluna GEOGRAPHY:

ALTER SESSION SET GEOGRAPHY_OUTPUT_FORMAT = 'WKT';

SELECT ST_UNION_AGG(g) AS union_of_shapes
  FROM st_union_agg_demo_table;
Copy
+-------------------------------------------------------------------------------------------+
| UNION_OF_SHAPES                                                                           |
|-------------------------------------------------------------------------------------------|
| GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,0 1,0 2),POLYGON((11 10,11 11,10 10,11 10))) |
+-------------------------------------------------------------------------------------------+