postgresql st_contains
时间: 2023-07-22 13:16:42 浏览: 58
`ST_Contains`是PostgreSQL中的一个空间函数,用于判断一个几何图形是否包含另一个几何图形。具体语法如下:
```sql
ST_Contains(geom1, geom2)
```
其中,`geom1`和`geom2`都是几何图形,可以是点、线、面等。返回值为布尔类型,如果`geom1`包含`geom2`,则返回`true`,否则返回`false`。
需要注意的是,`ST_Contains`函数的参数顺序很重要。如果要判断`geom2`是否包含`geom1`,则需要使用`ST_Contains(geom2, geom1)`。
相关问题
st_geomfromtext('${pointWkt}', 4326)
This code snippet is used in SQL queries to create a geometry object from a Well-Known Text (WKT) representation of a point. The pointWkt variable contains the WKT representation of the point, and 4326 is the spatial reference identifier (SRID) for the WGS 84 coordinate system.
The function st_geomfromtext() is a spatial function in PostGIS, a spatial extension for PostgreSQL. It creates a geometry object from a text representation of a geometry in WKT or GeoJSON format.
Example usage:
SELECT ST_AsText(ST_GeomFromText('POINT(-122.34900 47.65100)', 4326));
The above query will create a point geometry object from the WKT representation 'POINT(-122.34900 47.65100)', which represents a point at the longitude -122.34900 and latitude 47.65100, in the WGS 84 coordinate system. The ST_AsText() function will convert the geometry object back to a WKT representation, which will be 'POINT(-122.349 47.651)'.
postgresql的POLYGON
PostgreSQL中的POLYGON是一种几何数据类型,用于表示平面上的多边形。它由一组有序的点组成,首尾相连形成一个封闭的多边形。
在PostgreSQL中,可以使用以下语法来创建一个POLYGON类型的列:
```sql
CREATE TABLE my_table (
id SERIAL PRIMARY KEY,
polygon_column POLYGON
);
```
然后,可以将具体的多边形值插入到该列中:
```sql
INSERT INTO my_table (polygon_column) VALUES ('((0, 0), (0, 1), (1, 1), (1, 0), (0, 0))');
```
要查询包含或相交于指定POLYGON的行,可以使用PostgreSQL提供的几何函数和运算符。例如,可以使用ST_Contains函数来查找包含指定点的多边形:
```sql
SELECT * FROM my_table WHERE ST_Contains(polygon_column, POINT(0.5, 0.5));
```
这只是一些关于PostgreSQL中POLYGON数据类型的基本信息,如果你有更具体的问题,欢迎提问!
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![patch](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)