Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS Spatial data


SSIS Spatial data

Author
Message
clucasi
clucasi
SSC-Enthusiastic
SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)

Group: General Forum Members
Points: 101 Visits: 470
Hi All

I have converted a SQL 2007 database to a SQL 2008 as I need to use spatial data.
I have written a ssis task that reads data from a text file and writes the text to a sql2008 table, the problem i am having is that the longitude and latitude data is in a DT_WSTR format and i am not sure how to that into a geography data type as cannot see any any data types that match the geography data type
Stefan_G
Stefan_G
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 953
Unfortunately there is no built-in support in SSIS for spatial data.

You will have to implement it yourself.

The following articles might be helpful:

http://www.sql-server-performance.com/articles/biz/spatial_data_support_ssis_p1.aspx
http://msdn.microsoft.com/en-us/magazine/dd434647.aspx
clucasi
clucasi
SSC-Enthusiastic
SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)

Group: General Forum Members
Points: 101 Visits: 470
Being relatively new to SSIS 2008 could anybody help with transforming a text field to geography field, I have read the articles above and I still not sure (its also in c# and i am only have a bit of vb.net experience).
I have 3 fields an identifier (1) and an easting coordinate(384405.00) and a northing coordinate(402283.00) and need them to be identifier and geography data type.

A bit of help would be much appreciated:-D
Stefan_G
Stefan_G
Old Hand
Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)Old Hand (337 reputation)

Group: General Forum Members
Points: 337 Visits: 953
Ok, some more help:

I have created a sample SSIS package that can read data from a text file and write the data to a table containing a geometry column.

The package contains a flat file source, a script transform, and a OLE DB destination.

The flat file source extracts the Norting and Easting columns and feeds them into the script.
The script adds a new column pt with datatype DT_IMAGE.

My destination table is created using:
create table geo1 (id int, pt geometry)



The script looks like this:

/* Microsoft SQL Server Integration Services Script Component
* Write scripts using Microsoft Visual C# 2008.
* ScriptMain is the entry point class of the script.*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Types;
using System.Data.SqlTypes;
using System.IO;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{

MemoryStream ms;
BinaryWriter bw;

public override void PreExecute()
{
base.PreExecute();

// Only allocate these once
ms = new MemoryStream(10000);
bw = new BinaryWriter(ms);
}

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
// Create a SqlGeometry object representing the given data
SqlGeometry g = SqlGeometry.STPointFromText(new SqlChars("POINT ("+Row.Northing+" "+Row.Easting+")"),0);

// Serialize to a memory stream
ms.SetLength(0);
g.Write(bw);
bw.Flush();

// Copy data from memory stream to output column with DT_IMAGE format
Row.pt.AddBlobData(ms.GetBuffer(), (int)ms.Length);
}

}


Note that you need to add a reference to Microsoft.SqlServer.Types to the script.

In your application you might want to convert the northing and easting to geography (lat/long) but I have not done that to keep the sample simple.

I have included a SSIS 2008 project that you can use directly if desired.

Good luck
Attachments
SSIS_Spatial.zip (53 views, 21.00 KB)
Rick.Cornell.SME
Rick.Cornell.SME
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5305 Visits: 208
Sorry to jump in the middle of this but I needed somthing like this but thanks for the information.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search