Ask or search…
K
Links
Comment on page

accessors

CORE
This module contains functions that provide information about internal geometries.

ST_COORDDIM

ST_COORDDIM(geom)
Description
Returns the number of dimensions of the coordinates of Geometry geom.
  • geom: Geometry input geom.
Return type
Int
Example
1
SELECT carto.ST_COORDDIM(carto.ST_MAKEPOINTM(1, 2, 3));
2
-- 3

ST_DIMENSION

ST_DIMENSION(geom)
Description
Returns the inherent number of dimensions of this Geometry object, which must be less than or equal to the coordinate dimension.
  • geom: Geometry input geom.
Return type
Int
Example
1
SELECT carto.ST_DIMENSION(carto.ST_GEOMFROMWKT("LINESTRING(0 0, 1 1)"));
2
-- 1

ST_ENVELOPE

ST_ENVELOPE(geom)
Description
Returns a Geometry representing the bounding box of geom.
  • geom: Geometry input geom.
Return type
Geometry
Example
1
SELECT carto.ST_ASTEXT(carto.ST_ENVELOPE(carto.ST_GEOMFROMWKT("LINESTRING(1 1, 2 3)")));
2
-- POLYGON ((1 1, 1 3, 2 3, 2 1, 1 1))

ST_GEOMETRYN

ST_GEOMETRYN(geom, n)
Description
Returns the n-th Geometry (1-based index) of geom if the Geometry is a GeometryCollection, or geom if it is not.
  • geom: Geometry input geom.
  • n: Int input number of geom to take.
Return type
Geometry
Example
1
SELECT carto.ST_ASTEXT(
2
carto.ST_GEOMETRYN(
3
carto.ST_GEOMFROMWKT(
4
"GEOMETRYCOLLECTION(LINESTRING(1 1, 2 3), POINT(0 4), LINESTRING EMPTY)"
5
),
6
2
7
)
8
);
9
-- POINT (0 4)

ST_ISCLOSED

ST_ISCLOSED(geom)
Description
Returns true if geom is a LineString or MultiLineString and its start and end points are coincident. Returns true for all other Geometry types.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISCLOSED(carto.ST_GEOMFROMWKT("LINESTRING(1 1, 2 3, 4 3, 1 1)"));
2
-- true

ST_ISCOLLECTION

ST_ISCOLLECTION(geom)
Description
Returns true if geom is a GeometryCollection.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISCOLLECTION(
2
carto.ST_GEOMFROMWKT(
3
"GEOMETRYCOLLECTION(LINESTRING(1 1, 2 3), POINT(0 4)), LINESTRING EMPTY"
4
)
5
);
6
-- true

ST_ISEMPTY

ST_ISEMPTY(geom)
Description
Returns true if geom is an empty geometry.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISEMPTY(carto.ST_GEOMFROMWKT("LINESTRING EMPTY"));
2
-- true

ST_ISGEOMFIELD

ST_ISGEOMFIELD(geom)
Description
Returns true if geom is string containing WKT or WKB representation of a geometry.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISGEOMFIELD("LINESTRING(1 1, 2 3)");
2
-- true

ST_ISRING

ST_ISRING(geom)
Description
Returns true if geom is a LineString or a MultiLineString and is both closed and simple.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISRING(carto.ST_GEOMFROMWKT("LINESTRING(1 1, 2 3, 4 3, 1 1)"));
2
-- true

ST_ISSIMPLE

ST_ISSIMPLE(geom)
Description
Returns true if geom has no anomalous geometric points, such as self intersection or self tangency.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISSIMPLE(carto.ST_GEOMFROMWKT("LINESTRING(1 1, 2 3, 4 3, 2 3)"));
2
-- false

ST_ISVALID

ST_ISVALID(geom)
Description
Returns true if the Geometry is topologically valid according to the OGC SFS specification.
  • geom: Geometry input geom.
Return type
Boolean
Example
1
SELECT carto.ST_ISVALID(carto.ST_GEOMFROMWKT("POLYGON((0 0, 1 1, 1 2, 1 1, 0 0))"));
2
-- false

ST_NUMGEOMETRIES

ST_NUMGEOMETRIES(geom)
Description
If geom is a GeometryCollection, returns the number of geometries. For single geometries, returns 1,
  • geom: Geometry input geom.
Return type
Int
Example
1
SELECT carto.ST_NUMGEOMETRIES(
2
carto.ST_GEOMFROMWKT(
3
"GEOMETRYCOLLECTION(LINESTRING(1 1, 2 3), POINT(0 4), LINESTRING EMPTY)"
4
)
5
);
6
-- 3

ST_NUMPOINTS

ST_NUMPOINTS(geom)
Description
Returns the number of vertices in Geometry geom.
  • geom: Geometry input geom.
Return type
Int
Example
1
SELECT carto.ST_NUMPOINTS(carto.ST_GEOMFROMWKT("LINESTRING(1 1, 2 3, 4 4)"));
2
-- 3

ST_POINTN

ST_POINTN(geom, n)
Description
If geom is a LineString, returns the n-th vertex of geom as a Point. Negative values are counted backwards from the end of the LineString. Returns null if geom is not a LineString.
  • geom: Geometry input geom.
  • n: Int input number of vertex to take.
Return type
Point
Example
1
SELECT carto.ST_ASTEXT(
2
carto.ST_POINTN(
3
carto.ST_GEOMFROMWKT(
4
"LINESTRING(1 1, 2 3, 4 4, 3 4)"),
5
3
6
)
7
);
8
-- POINT (4 4)

ST_X

ST_X(geom)
Description
If geom is a Point, return the X coordinate of that point.
  • geom: Geometry input Point.
Return type
Double
Example
1
SELECT carto.ST_X(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
2
-- -76.09131

ST_Y

ST_Y(geom)
Description
If geom is a Point, return the Y coordinate of that point.
  • geom: Geometry input Point.
Return type
Double
Example
1
SELECT carto.ST_Y(carto.ST_POINT(-76.09130, 18.42750));
2
-- 18.4275