Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks Runtime 18.1 and above
Important
This feature is in Public Preview.
Returns the total number of rings of the input polygon or multipolygon, including exterior and interior rings. For a multipolygon, returns the sum of all rings across all polygons.
Syntax
st_nrings ( geoExpr )
Arguments
geoExpr: AGEOGRAPHYorGEOMETRYvalue.
Returns
An INTEGER value that represents the total number of rings in the input polygon or multipolygon.
Notes
The function returns NULL if the input is NULL.
Error conditions
- If
geoExpris not a polygon or multipolygon, the function returns ST_INVALID_ARGUMENT.INVALID_TYPE.
Examples
-- Example taking an empty 2D polygon GEOMETRY.
> SELECT st_nrings(st_geomfromtext('POLYGON EMPTY'));
0
-- Example taking a 4D polygon GEOGRAPHY with two rings (one exterior, one interior).
> SELECT st_nrings(st_geogfromtext('POLYGON ZM ((0 0 111 -11,10 0 222 -22,0 10 333 -33,0 0 444 -44),(1 1 555 -55,4 1 666 -66,1 4 777 -77,1 1 888 -88))'));
2
-- Example taking an empty 3DZ multipolygon GEOMETRY.
> SELECT st_nrings(st_geomfromtext('MULTIPOLYGON Z EMPTY', 4326));
0
-- Example taking a multipolygon GEOGRAPHY with four rings across two polygons.
> SELECT st_nrings(st_geogfromtext('MULTIPOLYGON (((0 0,10 0,10 10,0 10,0 0),(1 1,4 1,4 4,1 4,1 1),(5 5,6 5,6 6,5 6,5 5)),((20 20,30 20,30 30,20 30,20 20)))'));
4