如何使用PostgreSQL中的字段创建多边形? [英] How can I create a polygon using fields in PostgreSQL?

查看:114
本文介绍了如何使用PostgreSQL中的字段创建多边形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要合并成一个多边形的表中有8个实数值.我还没有办法弄清楚如何使用这些值创建多边形.我一直尝试

I have 8 real values in a table that I'd like to combine into a polygon. I haven't been able to figure out how to create a polygon using these values though. I keep trying variations of

SELECT polygon(lat1,lon1,lat2,lon2,lat3,lon3,lat4,lon4) FROM table;

,但不断遇到关于不存在的多边形函数或多边形类型的输入语法无效的错误.有人做过吗?

but keep getting errors about the polygon function not existing or an invalid input syntax for type polygon. Has anyone done this before?

推荐答案

常规postgres多边形的语法更像是:

The syntax for a regular postgres polygon is more like:

insert into geo_table values (1, '((2,2),(3,4),(3,6),(1,1))');

其中1是一些ID,引用的条目是多边形.我希望查询是类似的,您可能需要括号等作为坐标.通常对于所需的地理空间数据(经纬度)进行坐标. Postgis还采用 WKT 语句,例如:

Where 1 is some id and the quoted entry is the polygon. I would expect the query to be similar, you probably need parentheses etc for the coordinates. Typically for geospatial data you want (Lon Lat) coordinates. Postgis also takes WKT statements like:

GeomFromText('POLYGON((long1 lat1, long2 lat2, long3 lat3))')

这篇关于如何使用PostgreSQL中的字段创建多边形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆