ST_ GeohashCover
The ST_GeohashCover function returns the geohash cover of the specified geometry at the specified depth. A geohash cover is the set of geohash cells that are needed to completely cover a given geometry. A larger depth corresponds to smaller cells, and therefore results in more exact coverage (that is, less area of the geohash cover that is outside of the geometry). However, when the cells are smaller, more cells are needed.
Syntax
Parameter
- geometry
- A value of type ST_Geometry or one of its subtypes that represents the geometry for which the geohash cover values are to be calculated. If the specified geometry is NULL or empty, one row with a geohash value of NULL is returned.
- depth
- A value of type INTEGER in the range 1 - 45 that determines the size of the geohash cells that
comprise the geohash cover. The following table lists some of the most commonly used depths and
their corresponding approximate cell sizes.
Geohash Depth Approximate Cell Size Description Examples 45 0.1 km2 Single point or address GPS-location or house 28 3 km2 Small region city block 23 100 km2 Medium-sized region forest or lake 18 3,000 km2 Large region county or postal code area 13 100,000 km2 Very large (huge) region state or country Geohash values of two geometries that are to be compared must be computed using the same depth. An attempt to compare geohash values computed using different depths is invalid.
Shortcut functions
The following shortcut functions can be used instead of ST_GeohashCover:
| Shortcut Function | Description | Equivalent ST_ GeohashCover Function |
|---|---|---|
| ST_ GeohashCover_Small(geometry) | Returns the geohash cover of the specified geometry at depth 28. | ST_ GeohashCover(geometry,28) |
| ST_ GeohashCover_Medium(geometry) | Returns the geohash cover of the specified geometry at depth 23. | ST_ GeohashCover(geometry,23) |
| ST_ GeohashCover_Large(geometry) | Returns the geohash cover of the specified geometry at depth 18. | ST_ GeohashCover(geometry,18) |
| ST_ GeohashCover_Huge(geometry) | Returns the geohash cover of the specified geometry at depth 13. | ST_ GeohashCover(geometry,13) |
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 of type BIGINT with the name GEOHASH containing the geohash values of the specified geometry at the specified depth.
