1

I have a Shapefile (*.shp) which I am loading into the Database. I have a column called Point" which stores the Data in shapes. For example

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))

The data type of the Column "Point" is nvarchar(max).

The problem is when the size of Polygon exceeds , the column truncates and does not store all the values. I can't convert Points into Geometry as I want to convert Points into Lat/long from Polygon.

4

1 回答 1

3

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()
于 2012-10-09T23:06:19.287 回答