ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

ST_Aggr_Union

  • Definition
  • Syntax
  • Return type
  • Example

Definition

ST_Aggr_Union returns a single geometry that is the union of all input geometries.

Note that support for ST_Aggr_Union wih ST_Geometry in PostgreSQL begins with 10.5.1.

Syntax

Oracle and PostgreSQL

sde.st_aggr_union(geometry sde.st_geometry)

SQLite

st_aggr_union(geometry geometryblob)

Return type

Oracle and PostgreSQL

ST_Geometry

SQLite

Geometryblob

Example

A marketing analyst needs to create a single geometry of all the service areas for which sales exceeded 1,000 units. For this example, you will create a service_territories1 table and populate it with sales value numbers. You will then use st_aggr_union in a SELECT statement to return the multipolygon that is the union of all geometries for which sales numbers are equal to or greater than 1,000 units.

Oracle and PosgreSQL

--Create and populate tables.
CREATE TABLE service_territories1 (
 ID integer not null,
 UNITS number,
 SHAPE sde.st_geometry);

INSERT INTO service_territories1 (id, units, shape) VALUES (
 1, 
 1250,
 sde.st_polygon ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 4326)
);
 
INSERT INTO service_territories1 (id, units, shape) VALUES (
 2, 
 875,
 sde.st_polygon ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 4326)
);
 
INSERT INTO service_territories1 (id, units, shape) VALUES (
 3, 
 1700,
 sde.st_polygon ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 4326)
);
--Union of all geometries for which sales numbers are >= 1,000 units.
SELECT sde.st_astext(sde.st_aggr_union(shape)) UNION_SHAPE
  FROM service_territories1 
  WHERE units >= 1000;

UNION_SHAPE

MULTIPOLYGON  ((( 20.00000000 30.00000000, 30.00000000 30.00000000, 30.00000000
40.00000000, 20.00000000 40.00000000, 20.00000000 30.00000000)),(( 40.00000000 40.00000000, 
60.00000000 40.00000000, 60.00000000 60.00000000, 40.00000000 60.00000000, 
40.00000000 40.00000000)))

SQLite

--Create table, add geometry column to it, and populate table.
CREATE TABLE service_territories1 (
 id integer primary key autoincrement not null, 
 units number
);

SELECT AddGeometryColumn(
 NULL,
 'service_territories1',
 'shape',
 4326,
 'polygon',
 'xy',
 'null'
);

INSERT INTO service_territories1 (units, shape) VALUES (
 1250,
 st_polygon ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 4326)
);
 
INSERT INTO service_territories1 (units, shape) VALUES (
 875,
 st_polygon ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 4326)
);
 
INSERT INTO service_territories1 (units, shape) VALUES (
 1700,
 st_polygon ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 4326)
);
--Union of all geometries for which sales numbers are >= 1,000 units.
SELECT st_astext(st_aggr_union(shape)) 
 AS "UNION_SHAPE"
 FROM service_territories1 
 WHERE units >= 1000;

UNION_SHAPE

MULTIPOLYGON ((( 40.00000000 40.00000000, 60.00000000 40.00000000, 60.00000000 6
0.00000000, 40.00000000 60.00000000, 40.00000000 40.00000000)),(( 20.00000000 30
.00000000, 30.00000000 30.00000000, 30.00000000 40.00000000, 20.00000000 40.0000
0000, 20.00000000 30.00000000)))

Related topics

  • Load the SQLite ST_Geometry library

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2017 Esri. | Privacy | Legal