Posts

Showing posts with the label Geometry

Some practical SQL Spatial tips.

I have just finished a project were I made a lot of use of the SQL Spatial to do some processing and loading into the database. Here are some of lesson I learnt: The first method that needs to call after instantiating a SQLGeographybuilder object is: SetSrid() then the BeginGeography(), BeginPoint(). Before using sending a SQLGeometry object to the SQL Server use the IsVaild() function to ensure that Geometry object is valid. I create a console application which loaded line, which was using OS coordinates system, data from a flat file. Some of the line data within the file wasn’t as correct as I was led to believe. The application create the SQLGeometry object .NET but the Sql Server then rasied the error when it received and try to save it into the table. The STPointN() function is 1 base which is stated in the Books On-Line If your query needs to select some of the derive data from the functions you can help performance by using persisted compute columns on t...

How to load spatial data into SQL Server 2008 from .Net

I have been working on a project which made use of the spatial data type geography within SQL Server 2008. An issue that I had was how to load the geography data from a KML file into SQL Server 2008. Currently there is no out of the box tools to do this. There is a 3 rd party tool, Safe FME, which offer either their own tool or components which extend integration services. This was overkill for my issues as I only had to do it once. So I wrote a console application which parses the KML file to extract the point data convert it to a SqlGeography type and store it in the database. To use the SqlGeography C# type you need to add reference to the following name space: Microsoft.SqlServer.Types. This can be found in the following dll: Microsoft.SqlServer.Types.dll Then use the following code to create the c# sqlgeography type: 1: // use SqlGeographyBuilder to help create the SqlGeography type 2: SqlGeographyBuilder geographyBuilder = new SqlGeographyBuilder(); 3: s...

Business Intelligence with SQL Server 2008 Geometry Data Type.

Image
I am currently working on a project which is automating a business intelligence process base upon images and image recognition. The process is as follows: Take a photography Put the photography through the image recognition software and record the recognition data. Process the recognition data into meaningful business metrics Produce a report on metrics The part of the process, from above, that I am helping with is processing the recognition data (the hit data) into meaningful business data. This process simply takes the hit data (which is a point), then creates some square blocks, which I use to group the hits data and perform some metric operations. The metrics currently use data about the area and the density of hits within the area. To help process this data I decided to make use of the SQL Server 2008 spatial type: Geometry. Firstly I would like to point out that I didn’t have to use the geometry type. As I am currently dealing with square areas, I can group ...