

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# ST\$1GeomFromGeoHash
<a name="ST_GeomFromGeoHash-function"></a>

ST\$1GeomFromGeoHash 會從輸入幾何的 geohash 表示法建構幾何物件。ST\$1GeomFromGeoHash 會傳回空間參考識別碼 (SRID) 為零 (0) 的二維 (2D) 幾何。如需 geohash 格式的相關資訊，請參閱 Wikipedia 中的 [Geohash](https://en.wikipedia.org/wiki/Geohash)。

## 語法
<a name="ST_GeomFromGeoHash-function-syntax"></a>

```
ST_GeomFromGeoHash(geohash_string)
```

```
ST_GeomFromGeoHash(geohash_string, precision)
```

## 引數
<a name="ST_GeomFromGeoHash-function-arguments"></a>

 *geohash\$1string*   
`VARCHAR` 資料類型的值，或計算結果為 `VARCHAR` 類型的運算式，也就是幾何的 geohash 表示法。

 *precision*   
`INTEGER` 資料類型的值，代表 geohash 的精確度。該值是用作精確度的 geohash 的字元數。如果未指定該值，則小於零或大於 *geohash\$1string* 長度，則會使用 *geohash\$1string* 長度。

## 傳回類型
<a name="ST_GeomFromGeoHash-function-return"></a>

`GEOMETRY`

如果 *geohash\$1string* 為 null，則傳回 null。

如果 *geohash\$1string* 無效，則會傳回錯誤。

## 範例
<a name="ST_GeomFromGeoHash-function-examples"></a>

下列 SQL 會傳回高精確度的多邊形。

```
SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0'));
```

```
 st_asewkt       
-----------------------
 POLYGON((-115.172816 36.114646,-115.172816 36.114646,-115.172816 36.114646,-115.172816 36.114646,-115.172816 36.114646))
```

以下 SQL 會傳回高精確度的點。

```
SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz00'));
```

```
 st_asewkt       
-----------------------
 POINT(-115.172816 36.114646)
```

下列 SQL 會傳回低精確度的多邊形。

```
SELECT ST_AsText(ST_GeomFromGeoHash('9qq'));
```

```
 st_asewkt       
-----------------------
 POLYGON((-115.3125 35.15625,-115.3125 36.5625,-113.90625 36.5625,-113.90625 35.15625,-115.3125 35.15625))
```

下列 SQL 會傳回精確度為 3 的多邊形。

```
SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 3));
```

```
 st_asewkt       
-----------------------
 POLYGON((-115.3125 35.15625,-115.3125 36.5625,-113.90625 36.5625,-113.90625 35.15625,-115.3125 35.15625))
```