15.10 - Tessellate_Index Method - Teradata Database

Teradata Database SQL Geospatial Types

Teradata Database
Programming Reference

Returns the smallest cell that contains this object. The Tessellate_Index method is based on the concept of a multiple level g_nx by g_ny grid. The return value is suitable to use as an index key.


Argument …

Specifies …


the coordinates of the universe of interest.

The data type is FLOAT.


the number of grid cells to divide the universe into in the X and Y dimensions.

The data type is INTEGER.


the number of levels in the two-dimensional grid. There are always levels + 1 levels, where level 0 is the entire universe. Higher levels are more granular.

The data type is INTEGER and the range of values is 1 to 15.


the scaling factor between grid levels. For example, if g_nx * g_ny is 100x100 and level is 2 and scale is 0.1, you have a 3 level grid (100x100, 10x10, 1x1).

The data type of scale is FLOAT and the value must be greater than 0.0 and less than 1.0.


an INTEGER value that represents the number of times to shift the grid at each level. If the value of shift is 0, the method performs no shifting. If the value of shift is 1, the method creates four grids for each level, where it shifts each of the four grids in a unique manner.

Shifting the grid helps to avoid assigning smaller spatial objects to large cells if they cross a grid cell boundary.

The cell ID that is returned is an INTEGER value that codes for the cell number and level. The upper 28 bits identifies the cell number, and the lower four bits identifies the level.


Cell ID:


Cell Number


<------------ 28 bits -------------><-- 4 bits -->

To derive the cell number from the returned cell ID value using SQL, use:

return_value / 16

To derive the level from the returned cell ID using SQL, use:

return_value MOD 16

Here is an example that shows the cell numbering of a single-level grid (of unspecified size) that contains 16 cells.

All ST_Geometry types

CREATE TABLE sample_shapes(skey INTEGER, shape ST_Geometry);

INSERT INTO sample_shapes
  values(1067, NEW ST_Geometry('LineString(-43.5 20.2, -43.6 20.3)'));
   CREATE TABLE shapes_index
      (skey INTEGER
      ,cellid INTEGER);
   INSERT INTO shapes_index
   SELECT skey,
      shape.Tessellate_Index(-180, 0, 0, 90, 500, 500, 1, 0.01, 0)
   FROM sample_shapes;