The two functions ST_BuildArea and ST_Polygonize both take lines and produce polygons.

It seems that ST_BuildArea assumes that inner rings represent holes and omits them from the result, while ST_Polygonize includes them in the result. And the mechanics of using the functions are a bit different: ST_Polygonize is an aggregate, while ST_BuildArea requires that you bundle up the inputs yourself using ST_Collect.

Beyond this, are there any differences between the two functions?


This is not a complete answer, but could be a starting point for someone looking for more details.

ST_Polygonize (in the form of polygonize_garray) and ST_BuildArea are defined in the source code (mirror) at https://github.com/postgis/postgis/blob/svn-trunk/postgis/lwgeom_geos.c.

They both eventually call GEOSPolygonize, which is defined in GEOS, which is a C/C++ port of the Java Topology Suite.

And from the docs -

ST_Polygonize - Creates a GeometryCollection containing possible polygons formed from the constituent linework of a set of geometries. https://postgis.net/docs/ST_Polygonize.html

ST_BuildArea - Creates an areal geometry formed by the constituent linework of given geometry. The return type can be a Polygon or MultiPolygon, depending on input. If the input lineworks do not form polygons NULL is returned. The inputs can be LINESTRINGS, MULTILINESTRINGS, POLYGONS, MULTIPOLYGONS, and GeometryCollections. This function will assume all inner geometries represent holes. http://postgis.net/docs/ST_BuildArea.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.