ST_ GeohashCoverExtend

The ST_GeohashCoverExtend function returns the geohash values of all the cells that are needed to cover an area that corresponds to the specified cell plus a buffer zone surrounding that cell.

The buffer zone is the geometry that surrounds the input cell by a specified distance.
Figure 1. Geohash extension where the distance is less than the length of the side of one cell
The input cell is surrounded by a buffer zone. The size of the buffer zone is determined by the specified distance parameter. The output cells are all cells that are touched by the input cell and the buffer zone. The distance is slightly less than the length of the side of one cell, so a total of 9 cells are touched by the input cell and the buffer zone.
Figure 2. Geohash extension where the distance is greater than the length of the side of one cell
The input cell is surrounded by a buffer zone. The size of the buffer zone is determined by the specified distance parameter. The output cells are all cells that are touched by the input cell and the buffer zone. The distance is slightly greater than the length of the side of one cell, so a total of 25 cells are touched by the input cell and the buffer zone.

Syntax

Read syntax diagramSkip visual syntax diagram ) ST_GeohashCoverExtend(geohash,depth,distanceST_GeohashCoverExtend_Small(geohash,distanceST_GeohashCoverExtend_Medium(geohash,distanceST_GeohashCoverExtend_Large(geohash,distanceST_GeohashCoverExtend_Huge(geohash,distance,units )

Parameters

geohash
A value of type BIGINT that represents the geohash value of the input cell. If the specified geohash is NULL or empty, one row with a geohash value of NULL is returned. If the specified geohash is invalid, error GSE9990C is returned.
depth
A value of type INTEGER that identifies the depth of both the input geohash and the geohashes that are to be returned.
Important: These depths must be identical; otherwise, the result will not be accurate.
distance
The distance from the edge of the input cell that determines the size of the buffer zone. The value cannot be negative or null.
units
A VARCHAR(128) value that identifies the units of the specified distance. The only allowed value is 'METER', which is the default.

Shortcut functions

The following shortcut functions can be used instead of ST_GeohashCoverExtend:
Shortcut Function Description Equivalent ST_ GeohashCoverExtend Function
ST_ GeohashCoverExtend_Small(geohash, distance) The input and output geohashes have a depth of 28. ST_ GeohashCoverExtend(geohash, 28, distance)
ST_ GeohashCoverExtend_Medium(geohash, distance) The input and output geohashes have a depth of 23. ST_ GeohashCoverExtend(geohash, 23, distance)
ST_ GeohashCoverExtend_Large(geohash, distance) The input and output geohashes have a depth of 18. ST_ GeohashCoverExtend(geohash, 18, distance)
ST_ GeohashCoverExtend_Huge(geohash, distance) The input and output geohashes have a depth of 13. ST_ GeohashCoverExtend(geohash, 13, distance)

Restrictions

  • The number of rows returned by this function cannot exceed 10,000 (SQL0443N).
  • The specified geometry must use SRS 4326 (GSE3001N).

Output

A column with the name GEOHASH of type BIGINT containing the geohash values of the cells needed cover of the area that corresponds to the specified geohash cell after it has been extended in all dimensions by the specified distance.

Examples

Example 1
The following SQL statement returns the geohash values of the cells that are needed to cover the specified geohash cell, plus the area around that cell within a distance of 2 meters. The input and output geohashes are at depth 28, which corresponds to an area of about 3 km2.
select geohash from table(st_geohashcoverextend(-4609863165478961152,28, 2,'meter'))
The result is the input geohash (-4609863165478961152), plus the geohashes of the 8 neighboring cells. These are the 9 geohashes are needed to cover the area determined by the input parameters.
GEOHASH
--------------------
-4609863165480534016
-4609863165480009728
-4609863165474242560
-4609863165479485440
-4609863165478961152
-4609863165473193984
-4609863165467951104
-4609863165467426816
-4609863165461659648
Example 2
The following SQL statement returns the geohash values of the cells that are needed to cover the specified geohash cell, plus the area around that cell within a distance of 2000 meters or 2 km. The input and output geohashes are at depth 28, which corresponds to an area of about 3 km2.
select geohash from table(st_geohashcoverextend(-4609863165478961152,28, 2000,'meter'))
The result is the input geohash (-4609863165478961152), plus the geohashes of the 24 neighboring cells that are within the specified distance. These are the 25 geohashes are needed to cover the area determined by the input parameters.
GEOHASH
--------------------
-4609863990112681984
-4609863577795821568
-4609863440356868096
-4609861928528379904
-4609861791089426432
-4609863921393205248
-4609863509076344832
-4609863371637391360
-4609861859808903168
-4609861722369949696
-4609863715234775040
-4609863302917914624
-4609863165478961152
-4609861653650472960
-4609861516211519488
-4609863646515298304
-4609863234198437888
-4609863096759484416
-4609861584930996224
-4609861447492042752
-4609860691577798656
-4609860279260938240
-4609860141821984768
-4609858629993496576
-4609858492554543104