[postgis-users] aggregate different geometries

Braune, Christopher Christopher.Braune at LfU.Brandenburg.de
Mon May 20 06:51:38 PDT 2019


Hello postgis-community,

I'm searching for a solution to create aggregated geometries from a table with different single geometries. The input data looks like that:

id            foreign_key       geom
1             100                         point
2             200                         point
3             200                         point
4             300                         point
5             300                         point
6             300                         point
7             400                         point
8             400                         line
9             500                         point
10           500                         polygon

Now, I want to group this data by the "foreign_key". The result table have to be this structure:
foreign_key       geom
100                         point                     * result of one point
200                         line                        * result of two points
300                         polygon               * result of three points
400                         polygon               * result of one line and one point
500                         polygon               * result of one polygon and one point
600                        (...)                         * other combinations

The target is the smallest geometry that contains all single geometries. For example, three points creates a triangle-polygon.

My last try looks like this:

SELECT e. foreign_key,
                   ST_Multi(ST_makeline(e.geom)) as geom
                FROM gis_schema.single_objects e
GROUP BY e. foreign_key

(* Of course, polygons are not considered yet ;-)

Have anybody an idea? Thank's a lot!

Best regards,
Christopher


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20190520/23faf936/attachment.html>


More information about the postgis-users mailing list