Ask or search…
K
Links
Comment on page

formatters

CORE
This module contains functions that export geometries to an external format like WKT.

ST_ASBINARY

ST_ASBINARY(geom)
Description
Returns Geometry geom in WKB representation.
  • geom: Geometry input geom.
Return type
Array[Byte]
Example
1
SELECT carto.ST_ASBINARY(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
2
-- AIAAAAHAUwXX2/SH/UAybXCj1wo9AAAAAAAAAAA=

ST_ASGEOJSON

ST_ASGEOJSON(geom)
Description
Returns Geometry geom in GeoJSON representation.
  • geom: Geometry input geom.
Return type
Point
Example
1
SELECT carto.ST_ASGEOJSON(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
2
-- {"type":"Point","coordinates":[-76.0913,18.4275,0.0]}

ST_ASLATLONTEXT

ST_ASLATLONTEXT(p)
Description
Returns a String describing the latitude and longitude of Point p in degrees, minutes, and seconds. (This presumes that the units of the coordinates of p are latitude and longitude).
  • p: Point input point.
Return type
String
Example
1
SELECT carto.ST_ASLATLONTEXT(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
2
-- 18°25'39.000"N 77°54'31.320"W

ST_ASTEXT

ST_ASTEXT(geom)
Description
Returns Geometry geom in WKT representation.
  • geom: Geometry input geom.
Return type
String
Example
1
SELECT carto.ST_ASTEXT(carto.ST_POINT(-76.09130, 18.42750));
2
-- POINT (-76.0913 18.4275)

ST_ASTWKB

ST_ASTWKB(geom)
Description
Returns Geometry geom in TWKB representation.
  • geom: Geometry input geom.
Return type
Array[Byte]
Example
1
SELECT carto.ST_ASTWKB(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
2
-- 4QgBz/HU1QXwwN6vAQA=

ST_BITEARRAY

ST_BITEARRAY(s)
Description
Encodes string s into an array of bytes using the UTF-8 charset.
  • s: String input geom win WKT format.
Return type
Array[Byte]
Example
1
SELECT carto.ST_BYTEARRAY("POINT (-76.0913 18.4275)");
2
-- UE9JTlQgKC03Ni4wOTEzIDE4LjQyNzUp

ST_CASTTOGEOMETRY

ST_CASTTOGEOMETRY(geom)
Description
Casts Geometry subclass g to a Geometry. This can be necessary e.g. when storing the output of st_makePoint as a Geometry in a case class.
  • geom: Geometry input geom.
Return type
Geometry
Example
1
SELECT carto.ST_CASTTOGEOMETRY(carto.ST_POINT(-76.09130, 18.42750));
2
-- 4QgBz/HU1QXwwN6vAQA=

ST_CASTTOLINESTRING

ST_CASTTOLINESTRING(geom)
Description
Casts Geometry g to a LineString.
  • geom: Geometry input geom.
Return type
LineString
Example
1
SELECT carto.ST_CASTTOLINESTRING(carto.ST_GEOMFROMWKT('LINESTRING(75 29,77 29,77 27, 75 29)'));
2
-- 4QgBz/HU1QXwwN6vAQA=

ST_CASTTOPOINT

ST_CASTTOPOINT(geom)
Description
Casts Geometry g to a Point.
  • geom: Geometry input geom.
Return type
Point
Example
1
SELECT carto.ST_CASTTOPOINT(carto.ST_GEOMFROMWKT('POINT(75 29)'));
2
-- 4QgBgN6gywWAssiUAgA=

ST_CASTTOPOLYGON

ST_CASTTOPOLYGON(geom)
Description
Casts Geometry g to a Polygon.
  • geom: Geometry input geom.
Return type
Polygon
Example
1
SELECT carto.ST_CASTTOPOLYGON(carto.ST_GEOMFROMWKT('POLYGON((75 29, 77 29, 77 27, 75 29))'));
2
-- 4wgBAQSA3qDLBYCyyJQCAIC0iRMAAAD/s4kTAP+ziROAtIkTAA==

ST_GEOHASH

ST_GEOHASH(geom, prec)
Description
Returns the Geohash (in base-32 representation) of an interior point of Geometry geom. See Geohash for more information on Geohashes.
  • geom: Geometry input geom.
  • prec: Int input precision.
Return type
Point
Example
1
SELECT carto.ST_GEOHASH(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8);
2
-- d4