簡體   English   中英

POSTGIS多個多邊形ST_Intersects檢查

[英]POSTGIS multiple polygons ST_Intersects check

我在數組中設置了一組多邊形(不在數據庫中)。 我想檢查那些多邊形與另一個多邊形相交。

例:

input: [[], [], [], [], []] - set of polygons
want to checks those with another one polygon.
Return an array of true or false  

ST_intersects一次僅支持兩個多邊形。 是否可以一次檢查所有內容? 如果不是,我必須遍歷所有輸入的多邊形,並一一檢查。

謝謝。

您可以將ST_DUMPST_INTERSECTS函數組合為數組幾何(MULTIGEOMETRY TYPE)

St_astext(parcel.geom);

MULTIPOLYGON(((398140.945672642 4542263.06495453,398140.410405475 4542262.72839343,398140.513367039 4542263.18287079,398140.945672642 4542263.06495453)),
((398147.309882976 4542261.32904395,398146.58758329 4542258.33481488,398144.165643562 4542262.18667092,398147.309882976 4542261.32904395)),
((398141.915568335 4542238.96883738,398135.522133265 4542241.15138888,398138.811826236 4542255.67218681,398140.343422935 4542253.23633343,398146.254207604 4542256.95287011,398141.915568335 4542238.96883738)))

這是我的數據庫中的一個示例-已簽入;

select a.objectid,b.fid ,st_intersects (a.poly,b.geom)
from region a, 
(
select objectid::text||((st_dump(poly)).path[1]::text) as fid, (st_dump(poly)).geom as geom 
    from parcel where geometrytype(poly)='MULTIPOLYGON' ) 
  as b

http://www.postgis.org/docs/ST_Dump.html

http://postgis.org/docs/ST_Intersects.html

如果要知道至少一個輸入多邊形是否與目標多邊形相交,則可以將輸入表示為MultiPolygon數據類型。 這基本上就是您擁有的數組。 然后ST_Intersects接受一個Multipolygon單元。 但是,沒有選擇返回布爾值(真或假)數組的選項。

您可以在WKT Wiki頁面中看到MultiPolygon的WKT表示形式,對其進行構造並使用ST_GeomFromText轉換為PostGIS二進制文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM