Analytics Toolbox for Databricks

Analytics Toolbox for Databricks

indexing

This module contains functions used for indexing

ST_CRSFROMTEXT

Description

Creates a CoordinateReferenceSystem from a PROJ.4 projection parameter string.

  • proj4: String input projection parameter string.

Return type

Geometry

Example

1
2
SELECT carto.ST_CRSFROMTEXT('+proj=merc +lat_ts=56.5 +ellps=GRS80');
-- +proj=merc +lat_ts=56.5 +ellps=GRS80

ST_EXTENTFROMGEOM

Description

Creates a Geotrellis Extent from the given Geometry.

  • geom: Geometry input Geometry.

Return type

Extent

Example

1
2
SELECT carto.ST_EXTENTFROMGEOM(carto.ST_MAKEBBOX(0, 0, 1, 1))
-- {"xmin": 0, "ymin": 0, "xmax": 1, "ymax": 1}

ST_EXTENTTOGEOM

Description

Creates a Geometry representing the bounding box of the the given Geotrellis Extent.

  • extent: Extent input extent.

Return type

Geometry

Example

1
2
3
4
5
WITH t AS (
  SELECT carto.ST_EXTENTFROMGEOM(carto.ST_MAKEBBOX(0, 0, 1, 1)) as extent
)
SELECT carto.ST_ASTEXT(carto.ST_EXTENTTOGEOM(extent)) FROM t;
-- POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))

GEOMREPROJECT

Description

Transform a Geometry from The Common Reference System crsA to crsB.

  • geom: Geometry input geom.
  • crsA: CRS input crsA.
  • crsB: CRS input crsB.

Return type

Geometry

Example

1
2
3
4
5
6
7
WITH t AS (
  SELECT carto.ST_POINT(3, 5) AS point,
  carto.ST_CRSFROMTEXT('+proj=merc +lat_ts=56.5 +ellps=GRS80') AS crsa,
  carto.ST_CRSFROMTEXT('+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs') AS crsb
)
SELECT carto.ST_ASTEXT(carto.ST_GEOMREPROJECT(point, crsa, crsb)) FROM t;
-- POINT (0.00003 0.00005)

ST_MAKEEXTENT

Description

Creates a Extent representing a bounding box with the given boundaries.

  • lowerX: Double input lower x value.
  • lowerY: Double input lower y value.
  • upperX: Double input upper x value.
  • upperY: Double input upper y value.

Return type

Extent

Example

1
2
SELECT carto.ST_MAKEEXTENT(0, 0, 1, 1);
-- {"xmin": 0, "ymin": 0, "xmax": 1, "ymax": 1}