Storing 'Point' column from ShapeFile

放肆的年华 提交于 2019-12-08 19:02:28

I'd suggest storing the whole polygon as a geometry type. If/when you need to "convert" it to geography, use the geography methods STNumPoints and STPointN to extract the individual points in sequence and convert them as appropriate.

Speaking of the conversion, what format are your data in now? I'm not seeing lat/long info there, but perhaps I'm missing something.

Edit: Here's a solution that I just coded.

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()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!