Analytics Toolbox for Databricks

Analytics Toolbox for Databricks

formatters

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

ST_ASBINARY

Description

Returns Geometry geom in WKB representation.

  • geom: Geometry input geom.

Return type

Array[Byte]

Example

1
2
SELECT carto.ST_ASBINARY(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
-- AIAAAAHAUwXX2/SH/UAybXCj1wo9AAAAAAAAAAA=

ST_ASGEOJSON

Description

Returns Geometry geom in GeoJSON representation.

  • geom: Geometry input geom.

Return type

Point

Example

1
2
SELECT carto.ST_ASGEOJSON(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
-- {"type":"Point","coordinates":[-76.0913,18.4275,0.0]}

ST_ASLATLONTEXT

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
2
SELECT carto.ST_ASLATLONTEXT(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
-- 18°25'39.000"N 77°54'31.320"W

ST_ASTEXT

Description

Returns Geometry geom in WKT representation.

  • geom: Geometry input geom.

Return type

String

Example

1
2
SELECT carto.ST_ASTEXT(carto.ST_POINT(-76.09130, 18.42750));
-- POINT (-76.0913 18.4275)

ST_ASTWKB

Description

Returns Geometry geom in TWKB representation.

  • geom: Geometry input geom.

Return type

Array[Byte]

Example

1
2
SELECT carto.ST_ASTWKB(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'));
-- 4QgBz/HU1QXwwN6vAQA=

ST_BITEARRAY

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
2
SELECT carto.ST_BYTEARRAY("POINT (-76.0913 18.4275)");
-- UE9JTlQgKC03Ni4wOTEzIDE4LjQyNzUp

ST_CASTTOGEOMETRY

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
2
SELECT carto.ST_CASTTOGEOMETRY(carto.ST_POINT(-76.09130, 18.42750));
-- 4QgBz/HU1QXwwN6vAQA=

ST_CASTTOLINESTRING

Description

Casts Geometry g to a LineString.

  • geom: Geometry input geom.

Return type

LineString

Example

1
2
SELECT carto.ST_CASTTOLINESTRING(carto.ST_GEOMFROMWKT('LINESTRING(75 29,77 29,77 27, 75 29)'));
-- 4QgBz/HU1QXwwN6vAQA=

ST_CASTTOPOINT

Description

Casts Geometry g to a Point.

  • geom: Geometry input geom.

Return type

Point

Example

1
2
SELECT carto.ST_CASTTOPOINT(carto.ST_GEOMFROMWKT('POINT(75 29)'));
-- 4QgBgN6gywWAssiUAgA=

ST_CASTTOPOLYGON

Description

Casts Geometry g to a Polygon.

  • geom: Geometry input geom.

Return type

Polygon

Example

1
2
SELECT carto.ST_CASTTOPOLYGON(carto.ST_GEOMFROMWKT('POLYGON((75 29, 77 29, 77 27, 75 29))'));
-- 4wgBAQSA3qDLBYCyyJQCAIC0iRMAAAD/s4kTAP+ziROAtIkTAA==

ST_GEOHASH

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
2
SELECT carto.ST_GEOHASH(carto.ST_GEOMFROMWKT('POINT(-76.09130 18.42750)'), 8);
-- d4