我有兩個包含兩個多邊形實際座標的csv文件。我需要將csv文件的內容複製到名爲'sample'的PostGIS表中。我需要找到兩個多邊形和相交區域的交集。 enter image description here將csv文件複製到PostGIS表中
我是PostGIS中的新成員。請幫幫我。
我有兩個包含兩個多邊形實際座標的csv文件。我需要將csv文件的內容複製到名爲'sample'的PostGIS表中。我需要找到兩個多邊形和相交區域的交集。 enter image description here將csv文件複製到PostGIS表中
我是PostGIS中的新成員。請幫幫我。
假設WGS84:
第一創建表
create table sample (lat float, lon float);
然後將CSV到表(可能需要用定界符一些調整)。
copy sample from 'path_to_csv' delimiter ';' csv;
然後緯度經度轉換爲點(因此假設WGS84,SRID 4326):
alter table sample add column geom geometry(point, 4326)
using st_setsrid(st_makepoint(lon, lat),4326);
然後通過首先創建線串,則多邊形創建從點表中的多邊形。確保線串已關閉,這意味着第一個點必須等於最後一個點!
select st_makepolygon(st_makeline(geom)) geom
into polygon1
from sample;
爲了讓兩個多邊形的交集區域:
select filename, st_makepolygon(st_makeline(geom)) geom
into polygons
from sample
group by filename;
select st_area(st_intersection(a.geom,b.geom))
from polygons a, polygons b
where a.filename == 'part1' and b.filename == 'part2'
是一個很廣泛的話題......你什麼都已經嘗試過?你讀過這個了嗎? https://www.postgresql.org/docs/9.6/static/sql-copy.html –