postgresql - center - “没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。”

时间:2013-11-24 14:09:40

标签: postgresql postgis

在Slackware 14.0 x86_64上使用postgresql-9.2.4和postgis-2.0.3。 已将essex-latest.osm.pbf加载到数据库中。

我想要获得埃塞克斯的道路中心,但我遇到了问题。 这些工作还可以:

SELECT st_Extent(way), st_area(st_Extent(way)) from planet_osm_roads;    
       st_extent                    |     st_area          
------------------------------------------------+------------------
 BOX(-10979.62 6693910.54,144349.79 6822695.15) | 20004037488.3802



SELECT center(box '((-10979.62, 6693910.54),(144349.79, 6822695.15))');
         center          
-------------------------
 (66685.085,6758302.845) 

(但我想知道为什么函数是中心而不是st_center)。

无论如何,为什么这不起作用:

SELECT center(st_Extent(way)) from planet_osm_roads;
ERROR:  function center(box2d) does not exist
LINE 1: SELECT center(st_Extent(way)) from planet_osm_roads;
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

干杯, 彼得

2 个答案:

答案 0 :(得分:1)

函数中心获取类型框的参数,而不是st_Extent返回的box2d。使用ST_Centroid,您甚至无需调用st_Extent,尝试使用ST_Centroid(方式)

答案 1 :(得分:1)

center不是PostGIS功能,而是core geometry function for PostgreSQL

找到线串中点的最佳方法是使用linear referencing function(例如,ST_Line_Interpolate_Point()ST_LineInterpolatePoint()用于PostGIS> = 2.1)。

另见ST_PointOnSurface