1

これは、私が PostGIS メーリング リストに送信した電子メールからのクロス ポストです。

これまでのところ、点と線上の投影位置との間に線を作成する試みは長かったですが、ほぼそこに到達しました。昨日の時点で、最近傍分析を含める前に、次の画像に示す結果を得ました。

QGisのスクリーンショット

ご覧のとおり、ピンクの各ポイントは投影されたすべてのポイントに接続していますが、ピンクの各 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
4

2 に答える 2

1

問題は、関数が 2 番目の引数 (distguess) が整数ではなく倍精度であることを期待していると思うことです。1000000.0 を試すか、明示的にフロートするようにキャストしてみてください...

于 2009-09-24T20:27:05.920 に答える
1

結局、最近傍を使用する必要がないことがわかりました。線を接続している重心と同じIDを割り当てました

-- this sql script creates a line table that connects points 

-- delete existing tables if they exist
DROP TABLE exploded_roads;
DROP TABLE projected_points;
DROP TABLE lines_from_centroids_to_roads;


-- convert multi lines into lines
CREATE TABLE exploded_roads (
    the_geom    geometry,
    edge_id     serial
);

-- insert the linestring that don't need to be converted
INSERT INTO exploded_roads
SELECT the_geom
FROM "StreetCenterLines"
WHERE st_geometrytype(the_geom) = 'ST_LineString';


INSERT INTO exploded_roads
SELECT the_geom
FROM (
    SELECT ST_GeometryN(
    the_geom,
    generate_series(1, ST_NumGeometries(the_geom)))
    AS the_geom 
    FROM "StreetCenterLines"
)
AS foo;





-- create projected points table with ids matching centroid table
CREATE TABLE projected_points (
    the_geom    geometry,
    pid     serial,
    dauid       int
);


-- Populate Table
INSERT INTO projected_points(the_geom, dauid)
SELECT DISTINCT ON ("DAUID")
    ( 
        ST_Line_Interpolate_Point(
            exploded_roads.the_geom,
            ST_Line_Locate_Point(
                exploded_roads.the_geom,
                centroids.the_geom
            )
        )
    ),
    (centroids."DAUID"::int)

FROM exploded_roads, fred_city_o6_da_centroids centroids;


-- Create Line tables
CREATE TABLE lines_from_centroids_to_roads (
    the_geom    geometry,
    edge_id SERIAL
);


-- Populate Line Table
INSERT INTO lines_from_centroids_to_roads(
SELECT
    ST_MakeLine( centroids.the_geom, projected_points.the_geom )
FROM projected_points, fred_city_o6_da_centroids centroids
WHERE projected_points.dauid = centroids."DAUID"::int
);

-- Delete temp tables
--DROP TABLE exploded_roads;
--DROP TABLE projected_points;
于 2009-09-25T15:53:44.243 に答える