2017-06-02 166 views
1

我有一個查詢,在點圖層周圍50米的圓(緩衝區)中生成12個部分(餅狀楔)。在PostgreSQL/PostGIS中生成餅狀楔(幾何圖形)的ID

With buffer as(
SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom 
FROM my_point_table group by gid, geom 
UNION ALL 
SELECT gid as pt_id, geom FROM my_point_table 
) 
SELECT gid, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom 
FROM buffer 
GROUP BY pt_id 

我想ID指派給這些部分是這樣的:如何做到這將高度讚賞

assigning IDs to circle pie-like wedges

建議。

+0

所屬於[gis.se] –

+0

感謝您指出。我可能會問那裏。 –

回答

1

你可以嘗試這樣的事情

With my_point_table as (
    select 1 as gid, 'POINT(0 0)'::geometry as geom 
    union 
    select 2 as gid, 'POINT(1 1)'::geometry as geom 
), buffer as(
    SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom 
    FROM my_point_table group by gid, geom 
    UNION ALL 
    SELECT gid as pt_id, geom FROM my_point_table 
) , tr as (
    SELECT pt_id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom 
    FROM buffer 
    GROUP BY pt_id 
) 
select row_number() OVER (partition by pt_id), pt_id, geom from tr 

第一部分是嘲笑你的「my_point_table」表。

row_number()OVER(由pt_id分區) 是爲每個要素生成一個序列號。

+0

非常感謝。這很有幫助,但沒有按預期給出結果。我嘗試了模擬點和我自己的點層。 ID從1到6依次爲12,11,7,8,9,10。任何想法發生了什麼? –