这是我发送到 PostGIS 邮件列表的电子邮件中的交叉帖子
到目前为止,我在一个点和它在一条线上的投影位置之间创建一条线的努力已经很长了,但我快到了。截至昨天,在包括任何最近邻分析之前,我得到了这张图片中显示的结果:
如您所见,粉红色的每个点都连接到所有投影点,而我只想将每个粉红色 x 连接到其各自的投影。
在 IRC 上,建议我使用BostonGIS 的最近邻法。我将函数输入到 PostgreSQL 并尝试失败,如下所述。我假设我的错误是由于错误的参数类型造成的。我玩弄了它,将一些列的类型更改为 varchar,但我仍然无法让它工作。
关于我做错了什么的任何想法?关于如何解决它的任何建议?
代码:
-- this sql script creates a line table that connects points
-- convert multi lines into lines
CREATE TABLE exploded_roads AS
SELECT the_geom
FROM (
SELECT ST_GeometryN(
the_geom,
generate_series(1, ST_NumGeometries(the_geom)))
AS the_geom
FROM "StreetCenterLines"
)
AS foo;
-- Create line table that'll connect the centroids to the projected points on exploded lines
CREATE TABLE lines_from_centroids_to_roads (
the_geom geometry,
edge_id SERIAL
);
-- Populate Table
INSERT INTO lines_from_centroids_to_roads ( the_geom )
SELECT
ST_MakeLine(
centroids.the_geom,
(pgis_fn_nn(centroids.the_geom, 1000000, 1,1000, 'exploded_roads' ,'true', 'gid',
ST_Line_Interpolate_Point(
exploded_roads.the_geom,
ST_Line_Locate_Point(
exploded_roads.the_geom,
centroids.the_geom
)
)
)).*
)
FROM exploded_roads, fred_city_o6_da_centroids centroids;
DROP TABLE exploded_roads;
错误
NOTICE: CREATE TABLE will create implicit sequence "lines_from_centroids_to_roads_edge_id_seq" for serial column "lines_from_centroids_to_roads.edge_id"
ERROR: function pgis_fn_nn(geometry, integer, integer, integer, unknown, unknown, unknown, geometry) does not exist
LINE 28: (pgis_fn_nn(centroids.the_geom, 1000000, 1,1000, 'exploded...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function pgis_fn_nn(geometry, integer, integer, integer, unknown, unknown, unknown, geometry) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 584