ST_InteriorRingN

ST_InteriorRingN
Input polygon and the resulting interior ring.

ST_InteriorRingN takes a polygon column and a numeric value (n) and returns a linestring column. The output is the nth interior ring of the input polygon as a linestring. If there is more than one interior ring, the order of the interior rings is defined by the order in the input polygon. When n=0, the first interior ring is returned. If the index exceeds the number of interior rings in the polygon, null is returned. If the input is a multipolygon null is returned.

FunctionSyntax
Pythoninterior_ring_n(polygon, n)
SQLST_InteriorRingN(polygon, n)
ScalainteriorRingN(polygon, n)

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

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
11
12
from geoanalytics.sql import functions as ST, Polygon

data =[("POLYGON ((10 10, 40 10, 40 40, 10 40, 10 10),"+\
        "(15 15, 20 15, 20 30, 15 30, 15 15), (30 15, 35 15, 35 30, 30 30, 30 15))",),
       ("POLYGON ((20 0, 30 20, 40 0, 20 0))",)]

df = spark.createDataFrame(data, ["wkt"]) \
    .withColumn("polygon", ST.poly_from_text("wkt"))

df.select(ST.interior_ring_n("polygon", 1).alias("interior_ring_n")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
+-----------------------------------------------------+
|interior_ring_n                                      |
+-----------------------------------------------------+
|{"paths":[[[30,15],[30,30],[35,30],[35,15],[30,15]]]}|
|NULL                                                 |
+-----------------------------------------------------+

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.