# Geospatial Functions

Geospatial functions allow working with location-based data, including points, coordinates, polygons, and spatial indexes. They enable conversion, querying, and analysis of geographic information

### **H3 Functions**

#### <mark style="color:purple;">H3\_LATLNG\_TO\_CELL</mark>

Converts latitude/longitude into an H3 cell index (INT).

```
H3_LATLNG_TO_CELL(lat, lng, res)
```

#### <mark style="color:purple;">H3\_LATLNG\_TO\_CELLADDRESS</mark>

Converts lat/lng into an H3 cell address (STRING).

```
H3_LATLNG_TO_CELLADDRESS(lat, lng, res)
```

#### <mark style="color:purple;">H3\_CELL\_TO\_PARENT</mark>

Gets the parent cell index for a given cell.

```
H3_CELL_TO_PARENT(cell, parent_res)
```

#### <mark style="color:purple;">H3\_CELLADDRESS\_TO\_PARENT</mark>

Gets the parent cell address for a given cell address.

```
H3_CELLADDRESS_TO_PARENT(cell_address, parent_res)
```

#### <mark style="color:purple;">H3\_CELL\_TO\_CELLADDRESS</mark>

Converts an H3 numeric cell index to its alphanumeric cell address.

```
H3_CELL_TO_CELLADDRESS(cell_index)
```

#### <mark style="color:purple;">H3\_CELLADDRESS\_TO\_CELL</mark>

Converts H3 cell address back to numeric index.

```
H3_CELLADDRESS_TO_CELL(cell_address)
```

#### <mark style="color:purple;">H3\_CELL\_TO\_LATLNG</mark>

Returns the lat/lng center of a cell as an array \[lat, lng].

```
H3_CELL_TO_LATLNG(cell_index)
```

#### <mark style="color:purple;">H3\_CELLADDRESS\_TO\_LATLNG</mark>

Returns the lat/lng center of a cell address.

```
H3_CELLADDRESS_TO_LATLNG(cell_address)
```

#### <mark style="color:purple;">H3\_CELL\_TO\_BOUNDARY\_AS\_GEOJSON</mark>

Returns the cell boundary as a GeoJSON polygon.

```
H3_CELL_TO_BOUNDARY_AS_GEOJSON(cell)
```

#### <mark style="color:purple;">H3\_POINT\_TO\_CELL</mark>

Converts an ST\_POINT geometry to an H3 index.<br>

```
H3_POINT_TO_CELL(point, res)
```

#### <mark style="color:purple;">H3\_POINT\_TO\_CELLADDRESS</mark>

Converts an ST\_POINT geometry to an H3 cell address.

```
H3_POINT_TO_CELLADDRESS(point, res)
```

#### <mark style="color:purple;">H3\_POLYGON\_TO\_CELLS</mark>

Returns list of H3 cell indices covering a GeoJSON polygon.

```
H3_POLYGON_TO_CELLS(geojson, res)
```

#### <mark style="color:purple;">H3\_POLYGON\_TO\_CELLADDRESSES</mark>

Returns list of H3 cell addresses covering a GeoJSON polygon.

```
H3_POLYGON_TO_CELLADDRESSES(geojson, res)
```

#### <mark style="color:purple;">H3\_GRID\_DISK</mark>

Returns neighboring cells within hex distance *k*.

```
H3_GRID_DISK(cell, k)
```

### **Bing Tile Functions**

#### <mark style="color:purple;">BING\_TILE\_AT</mark>

Returns the Bing tile ID at the given location and zoom level.

```
BING_TILE_AT(lat, lng, level)
```

#### <mark style="color:purple;">BING\_TILE\_QUADKEY</mark>

Converts a Bing tile ID to its QuadKey representation.

```
BING_TILE_QUADKEY(tile_id)
```

### **ST Functions**

#### <mark style="color:purple;">ST\_POINT</mark>

Creates a GEOGRAPHY point (lng, lat).

```
ST_POINT(lng, lat)
```

#### <mark style="color:purple;">ST\_CONTAINS</mark>

Checks whether one geography fully contains another.

```
ST_CONTAINS(geogA, geogB)
```
