st_point
时间: 2023-06-22 15:23:52 浏览: 44
`ST_Point`是PostgreSQL中的一个空间函数,用于创建一个点几何图形。具体语法如下:
```sql
ST_Point(x, y)
```
其中,`x`和`y`分别是点的横坐标和纵坐标。返回值为一个点几何图形。例如,要创建一个坐标为(1,2)的点,可以使用以下语句:
```sql
SELECT ST_Point(1, 2);
```
返回的结果为:
```
st_point
------------
POINT(1 2)
(1 row)
```
需要注意的是,函数返回的点几何图形采用WKT (Well-known text)格式表示,其中`POINT`为几何类型,`(1 2)`为点的坐标。
相关问题
用类写这段代码#网格id查找四个顶点 l_grid_id = [] #网格id,以矩阵形式保存,eg:(1,1)表示第一行第一列的矩阵,按x轴遍历 l_1st_point = [] #第一个点坐标,左下 l_2nd_point = [] #第二个点坐标,左上 l_3rd_point = [] #第三个点坐标,右下 l_4th_point = [] #第四个点坐标,右上 for i in range(grid_num_x): for j in range(grid_num_y): each_grid_id = (i + 1, j + 1) each_1st_point = (i * unit_length, j * unit_width) each_2nd_point = (i * unit_length, (j + 1) * unit_width) each_3rd_point = ((i + 1) * unit_length, j * unit_width) each_4th_point = ((i + 1) * unit_length, (j + 1) * unit_width) l_grid_id.append(each_grid_id) l_1st_point.append(each_1st_point) l_2nd_point.append(each_2nd_point) l_3rd_point.append(each_3rd_point) l_4th_point.append(each_4th_point)
以下是用类编写的代码:
```python
class Grid:
def __init__(self, grid_num_x, grid_num_y, unit_length, unit_width):
self.l_grid_id = [] # 网格id,以矩阵形式保存,eg:(1,1)表示第一行第一列的矩阵,按x轴遍历
self.l_1st_point = [] # 第一个点坐标,左下
self.l_2nd_point = [] # 第二个点坐标,左上
self.l_3rd_point = [] # 第三个点坐标,右下
self.l_4th_point = [] # 第四个点坐标,右上
for i in range(grid_num_x):
for j in range(grid_num_y):
each_grid_id = (i + 1, j + 1)
each_1st_point = (i * unit_length, j * unit_width)
each_2nd_point = (i * unit_length, (j + 1) * unit_width)
each_3rd_point = ((i + 1) * unit_length, j * unit_width)
each_4th_point = ((i + 1) * unit_length, (j + 1) * unit_width)
self.l_grid_id.append(each_grid_id)
self.l_1st_point.append(each_1st_point)
self.l_2nd_point.append(each_2nd_point)
self.l_3rd_point.append(each_3rd_point)
self.l_4th_point.append(each_4th_point)
```
在这个类中,我们定义了一个构造函数 `__init__`,用于初始化网格的相关信息,即 `grid_num_x` 表示横向的网格数量,`grid_num_y` 表示纵向的网格数量,`unit_length` 表示每个网格的长度,`unit_width` 表示每个网格的宽度。然后我们定义了四个列表 `l_grid_id`、`l_1st_point`、`l_2nd_point` 和 `l_3rd_point`,分别用于保存网格的 id、左下角、左上角和右下角的坐标。在类的构造函数中,我们使用两个 for 循环遍历所有的网格,根据每个网格的位置计算出对应的 id 和四个点的坐标,并将它们添加到相应的列表中。注意,在类中我们使用了 `self.` 来表示类的实例属性,这样我们才能在类的方法中使用这些属性。
st_point() { }
`ST_Point()` 是 PostGIS 中用于创建一个点几何对象的函数。它接受两个参数,分别是 x 和 y 坐标,如下所示:
```sql
ST_Point(x, y)
```
例如,要创建一个坐标为 (1, 2) 的点对象,可以使用以下语句:
```sql
SELECT ST_Point(1, 2);
```
这将返回一个点几何对象,其几何表示为 `POINT(1 2)`。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)