2012-10-09 54 views
1

我有一個Shapefile(* .shp),我正在加載到數據庫中。我有一個名爲點列」,其存儲在形狀數據。例如從ShapeFile中存儲'Point'列

POLYGON ((1543297.7815 5169880.9468, 1543236.7046 5169848.3834, 
      1543195.0218 5169930.2767, 1543104.4989 5170101.6818, 
      1543056.805 5170191.9835, 1542969.1187 5170358.1396, 
      1542820.9656 5170638.8525, 1542820.6605 5170639.7223, 
      1542816.1912 5170647.8707, 1543158.2618 5170829.6437, 
      1543318.4126 5170915.6562, 1543559.2078 5171043.8001, 
      1543840.2014 5171192.4698, 1544108.917 5171336.1306, 
      1544271.7972 5171422.313, 1544357.0262 5171263.5454, 
      1544447.9779 5171091.3804, 1544468.04 5171054.3179, 
      1544529.7931 5170936.192, 1544583.3416 5170837.5321, 
      1544658.3376 5170696.5608, 1544699.0638 5170622.0859, 
      1543985.6169 5170245.4526, 1543618.4129 5170050.7422, 
      1543297.7815 5169880.9468)) 

列的數據類型‘點’是nvarchar(max)

當多邊形的大小超過的問題是,該列截斷,並不存儲所有的值我不能將點轉換爲幾何,因爲我想從多邊形轉換成緯/長

回答

3

我建議將整個多邊形存儲爲幾何類型如果/當您需要將其「轉換」爲地理位置時,請使用地理方法STNumPoints和STPointN按順序提取各個點並適當轉換它們。

說到轉換,現在你的數據是什麼格式?我沒有看到緯度/經度信息,但也許我錯過了一些東西。

編輯:這是我剛剛編碼的解決方案。

use tempdb; 
create table tally (i int not null); 
with 
    a as (select 1 as [i] union select 0), 
    b as (select 1 as [i] from a as [a1] cross join a as [a2]), 
    c as (select 1 as [i] from b as [a1] cross join b as [a2]), 
    d as (select 1 as [i] from c as [a1] cross join c as [a2]), 
    e as (select 1 as [i] from d as [a1] cross join d as [a2]) 
insert into tally 
select row_number() over (order by i) from e 
create unique clustered index [CI_Tally] on tally (i) 

create table ace (g geometry) 
insert into ace (g) 
values (geometry::STGeomFromText(<<your polygon string here>>, 0)); 

select i, g.STPointN(t.i), g.STPointN(t.i).STAsText() 
from ace as [a] 
cross join tally as [t] 
where t.i <= g.STNumPoints() 
+0

嗨那裏謝謝你的回覆。我的數據是NZTM(新西蘭格式),我需要轉換成緯度/長度,但使用C#程序。根據你的建議,我需要將我的點轉換成幾何,然後再轉換成點?你能舉出一個例子,我該如何轉換它?例如我的上面的多邊形? –

+0

乾杯隊友..這個作品!謝謝你.. –

+1

我的榮幸。保持這張桌子四周;他們真的很有用!如果你還不知道自己的榮耀,那麼請自己幫忙,把「理財表sql」放到你最喜歡的搜索引擎中。 –