Often it is necessary to grasp for cartographic purposes unconnected polygons together and to generalize in this way. E.g. if groups are to be taken from individual buildings to a residential area together. With the PostGIS aggregation function aggregatepolygons() developed by Kappasys, this aggregation can be performed easily.
The aggregation function aggregatepolygons (geometry, double precision, boolean) expects three parameter
In order to avoid not valid geometries during the aggregation process first the cleangeometry() function has to be installed (see Downloads). In the second step, install the aggregation function aggregatepolygons() .
$ psql <dbname> -U <user> -h <server> -f cleanGeometry.sql
$ psql <dbname> -U <user> -h <server> -f aggregatePolygons.sql
Example 1: Orthogonal Aggregation of Buildings
Figure 1 shows the result of an orthogonal aggregation of buildings.
select aggregatepolygons(wkb_geometry, 50, true) from buildings group by art;
Example 2: non Orthogonal Aggregation
The result of a non-orthogonal aggregation is shown in Figure 2. As a rule, natural objects such as e.g. Forest summarized in this way.
select aggregatepolygons(wkb_geometry, 50, false) from forest group by art;