简体   繁体   English

sql数据库转空间数据库

[英]sql database into spatial database

I want to know how to convert a SQL database in to SQL spatial db.我想知道如何将 SQL 数据库转换为 SQL 空间数据库。 I have a SQL database "Register" which contains some tables as cables, components, etc. How can I make this database Spatial database.我有一个 SQL 数据库“Register”,其中包含一些表格,如电缆、组件等。我如何制作这个数据库空间数据库。 Can somebody help me with how to do it?有人可以帮助我如何做吗?


I forgot to say that the database is SQL Server 2008, version 10.50.1600.1 I'm trying to find a description on the Internet, how to do it, but unfortunately I can not find.忘了说数据库是SQL Server 2008, version 10.50.1600.1 我想在网上找说明,怎么弄,可惜找不到。

If your asking how to convert latitude and longitude coordinates into spatial data, Sql server 2008 has functions like STGeomFromText that can be utilized like如果您询问如何将纬度和经度坐标转换为空间数据,Sql server 2008 具有像 STGeomFromText 这样的函数,可以像这样使用

INSERT INTO SpatialTable (GeogCol1)
VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));
GO

Or if you want to add a spatial column, you could use a computed column and add或者,如果要添加空间列,可以使用计算列并添加

geography::STGeomFromText('Point('+LongitudeColumn+' '+LatitudeColumn+')', 4326)

to the default value.到默认值。 This would work well for a spatial point.这对于空间点很有效。 If you needed to do more complex shapes like polygons and polylines, I would suggest searhing here and here如果你需要做更复杂的形状,比如多边形和折线,我建议在这里这里搜索

It would be great to know what types of spatial data are you looking to store in your "spatial" database.很高兴知道您希望在“空间”数据库中存储哪些类型的空间数据。 Point (cities as an example), line (streets), polygons (sales areas) .点(以城市为例)、线(街道)、多边形(销售区域)。 Nothing makes a database spatial but tables that contain geometry and geography datatype fields make tables spatial.没有什么可以使数据库具有空间性,但是包含几何和地理数据类型字段的表可以使表具有空间性。 Create a table with a field of datatype geometry or geography and think about what you want to store in it (Points, Lines, Polygons) is a good start.创建一个包含几何或地理数据类型字段的表,并考虑要在其中存储什么(点、线、多边形)是一个好的开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM