mysqlgis

Does MySQL have an aggregate ST_UNION()?


I'm struggling for hours to get my query work but with no success.

I have a table with a GEOMETRY column which stores the POLYGON of a given area from sub-localities. Now i want to Union them all to one higher level boundary of the parent area for example:

SELECT ST_Union(geometry) FROM area

I always the the error:

#1582 - Incorrect parameter count in the call to native function 'ST_Union'

I don't think that this is the wanted behaviour of the function, since this makes it completely worthless. Does anybody know how to use this function to generate the intended results?


Solution

  • MySQL doesn't have an aggregate form of ST_Union, or any other spatial function.

    If you're looking for spatial aggregates you'll have to migrate to PostgreSQL/PostGIS. MySQL has only minimal GIS functionality.

    SELECT ST_Union( Point(0,0), Point(0,1) );
    

    For a comparison of MySQL and PostgreSQL, see my post here