Spatial Data Implementation In SQL Server Demo




               Spatial data represents information about the physical location and shape of geometric objects. These objects can be point locations or more complex objects such as countries, roads, or lakes.                                                 
                           Spatial data is defined as data that is represented by 2D or 3D images. SQL Server 2008 supports 2D images. Spatial data can be further subdivided into geometric data (data that can use calculations involving Euclidian geometry) and geographic data (data that identifies geographic locations and boundaries on the earth).

                       A spatial database is a database that is optimized to store and query data related to objects in space, including points, lines and polygons. While typical databases can understand various numeric and character types of data, additional functionality needs to be added for databases to process spatial data types

SQL Server supports two spatial data types: the geometry data type and the geography data type.

  • The geometry type represents data in a Euclidean (flat) coordinate system.
  • The geography type represents data in a round-earth coordinate system.
Both data types are implemented as .NET common language runtime (CLR) data types in SQL Server.

Below is basic implementation demo of spatial data


USE Spatial
GO
IF OBJECT_ID ( 'dbo.Spatial_Table', 'U' ) IS NOT NULL
    DROP TABLE dbo.SpatialTable;
GO

CREATE TABLE Spatial_Table
    ( id int IDENTITY (1,1),
    GM1 geometry,
    GM2 AS GM1.STAsText() );
GO


INSERT INTO Spatial_Table (GM1) VALUES (geometry::STGeomFromText('POLYGON ((0 0, 10 0, 150 150, 0 15, 0 0))', 0));
INSERT INTO Spatial_Table (GM1) VALUES (geometry::STGeomFromText('POLYGON ((0 0, 10 0, 150 150, 0 15, 0 0))', 0));
INSERT INTO Spatial_Table (GM1) VALUES (geometry::STGeomFromText('POLYGON ((0 0, 100 0, 150 15, 10 15, 0 0))', 0));
GO

Select * from Spatial_Table








No comments:
Write comments

Please do not enter spam links

Meet US

Services

More Services