简体   繁体   中英

sql database into spatial database

I want to know how to convert a SQL database in to SQL spatial db. I have a SQL database "Register" which contains some tables as cables, components, etc. How can I make this database Spatial database. 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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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