

 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\$1GeomFromGeoSquare
<a name="ST_GeomFromGeoSquare-function"></a>

st\$1GeomfromFromsquare 會傳回涵蓋由輸入 geosquare 值所表示之區域的幾何。傳回的幾何永遠是二維的。若要計算 geosquare 值，請參閱 [ST\$1GeoSquare](ST_GeoSquare-function.md)。

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

```
ST_GeomFromGeoSquare(geosquare)
```

```
ST_GeomFromGeoSquare(geosquare, max_depth)
```

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

 *geosquare*   
`BIGINT` 資料類型的值或計算結果為 geosquare 值之 `BIGINT` 類型的運算式，該值描述在初始域上進行的細分序列以達到所需的平方。此值由 [ST\$1GeoSquare](ST_GeoSquare-function.md) 計算。

 *max\$1depth*   
`INTEGER` 資料類型的值，代表對初始域進行的域細分的最大數量。值必須等於或大於 `1`。

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

`GEOMETRY`

如果 *geosquare* 無效，則函數會傳回錯誤。

如果輸入 *max\$1depth* 不在範圍內，則函數會傳回錯誤。

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

下列 SQL 會從 geosquare 值傳回幾何。

```
SELECT ST_AsText(ST_GeomFromGeoSquare(797852));
```

```
 st_astext       
--------------------------------------------------------------------------------------------------------------------
 POLYGON((13.359375 52.3828125,13.359375 52.734375,13.7109375 52.734375,13.7109375 52.3828125,13.359375 52.3828125))
```

下列 SQL 會從 geosquare 值和最大深度 `3` 傳回幾何。

```
SELECT ST_AsText(ST_GeomFromGeoSquare(797852, 3));
```

```
 st_astext       
--------------------------------------
 POLYGON((0 45,0 90,45 90,45 45,0 45))
```

以下 SQL 首先透過指定 x 座標為經度、y 座標為緯度 (-122.3, 47.6) 來計算西雅圖的 geosquare 值。然後它傳回 geosquare 的多邊形。雖然輸出是二維幾何，但它可以用來計算經度和緯度的空間資料。

```
SELECT ST_AsText(ST_GeomFromGeoSquare(ST_GeoSquare(ST_Point(-122.3, 47.6))));
```

```
 st_astext
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
POLYGON((-122.335167014971 47.6080129947513,-122.335167014971 47.6080130785704,-122.335166931152 47.6080130785704,-122.335166931152 47.6080129947513,-122.335167014971 47.6080129947513))
```