从ShapeFile存储“点"列 [英] Storing 'Point' column from ShapeFile

查看:51
本文介绍了从ShapeFile存储“点"列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Shapefile(* .shp),正在加载到数据库中.我有一列称为点"的列,该列将数据存储为形状.例如

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

点"列的数据类型为nvarchar(max).

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

问题是当Polygon的大小超过时,该列将被截断并且不存储所有值.我无法将点转换为几何,因为我想将点从多边形转换为纬度/经度.

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.

推荐答案

我建议将整个多边形存储为几何类型.如果/当您需要将其转换"为地理时,请使用地理方法STNumPoints和STPointN依次提取各个点并将其适当转换.

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.

这是我刚刚编写的解决方案.

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

这篇关于从ShapeFile存储“点"列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆