ST_MultiPolygon

ST_MultiPolygon takes an array column and returns a polygon column. The input column must contain an array of arrays of point geometries. The output polygon column represents the one or more rings created from the point arrays.

FunctionSyntax
Pythonmultipolygon(*point_arrays)
SQLST_MultiPolygon(*point_arrays)
Scalamultipolygon(pointArrays)

For more details, go to the GeoAnalytics Engine API reference for multipolygon.

This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
from geoanalytics.sql import functions as ST, Point

df = spark.createDataFrame([([[Point(0, 0), Point(10, 5), Point(15, 15), Point(0,0)]], ),
                            ([[Point(0, 0), Point(10, 0), Point(20, 10), Point(0,0)],
                              [Point(20, 30), Point(18, 28), Point(18, 28), Point(18, 28), Point(20, 30)]], )],
                           ["point_arrays"])

df.select(ST.multipolygon("point_arrays").alias("multipolygon")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
+----------------------------------------------------------------------------------+
|multipolygon                                                                      |
+----------------------------------------------------------------------------------+
|{"rings":[[[0,0],[10,5],[15,15],[0,0]]]}                                          |
|{"rings":[[[0,0],[10,0],[20,10],[0,0]],[[20,30],[18,28],[18,28],[18,28],[20,30]]]}|
+----------------------------------------------------------------------------------+

Version table

ReleaseNotes

1.0.0

Python and SQL functions introduced

1.5.0

Scala function introduced

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.