SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Investigating the new Spatial Types in SQL Server 2008 - Part 2


Investigating the new Spatial Types in SQL Server 2008 - Part 2

Author
Message
Bennie Haelen
Bennie Haelen
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 Visits: 63
Comments posted to this topic are about the item Investigating the new Spatial Types in SQL Server 2008 - Part 2
Duong Qua
Duong Qua
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 24
Good article. 5 stars from me.

Waiting for ArcSDE interface.
alastair-804470
alastair-804470
SSC-Enthusiastic
SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)

Group: General Forum Members
Points: 145 Visits: 105
Another good article. Well done.

Readers might want to note that the spatial reference identifier not only refers to projected spatial reference systems as suggested, but to geodetic spatial reference systems too (i.e. ones based on lat/long coordinates).
In fact, the sys.spatial_reference_systems table is *only* used for non-projected spatial reference systems, since these are required to apply the relevant model of curvature to the earth when using the geography datatype.
When using a projected system based on the geometry datatype, it doesn't matter what SRID is supplied - the results obtained of any methods will be the same.

For any readers wanting a further introduction to different spatial reference systems, and their signficance to the geometry and geography datatype, try:
"Beginning Spatial with SQL Server 2008" (Apress)
http://www.apress.com/book/view/9781430218296
Harry Bouckley-440138
Harry Bouckley-440138
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 12
Thanks for Spatial documents and code. They all show points in text, but I want to take data from one table in sql 2005, which holds X & Y values and create Points in SQL 2008.
For normal data I would write something like :
Insert into NewTable (NewX, NewY) Select X, Y from OldTable
As SQL 2008 uses geometry::STPointFromText('POINT(20 25)', 0), what do I use for a recursive call, I cannot put geometry::STPointFromText('POINT(X Y)', 0).
The only method I have found so far is to extract the data to a text file, include all the SQL commands, then use the file as an SQL file to run. I thought of CTE, but surely I am missing something, it has to be easier.
Except for some grey cells, what am I missing, can you give some examples for a simple transfer?
Thanks
Harry
alastair-804470
alastair-804470
SSC-Enthusiastic
SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)SSC-Enthusiastic (145 reputation)

Group: General Forum Members
Points: 145 Visits: 105
I think you're making this more complicated than it needs to be! You can construct the WKT representation of a point by concatenating together the string values of each coordinate, and then passing that to the STPointFromText() method, as follows:


INSERT INTO NewTable (point)
SELECT
geometry::STPointFromText('POINT('+ CAST(X AS varchar(255)) + ' ' + CAST(Y AS varchar(255)) + ')',0)
FROM
OldTable



Alternatively, if it's only points that you're creating, you'll probably find it easier to use the Point() method instead. Point() accepts two floating point coordinate values directly (X/Y, or Lat/Lng), so you don't have to bother with the CASTing:


INSERT INTO NewTable (point)
SELECT
geometry:: Point(X,Y,0)
FROM
OldTable



Note: You should not include a space between the double colons of geometry:: and the word Point in the above example - it's just that I needed to insert the space to stop the emoticon Tongue appearing!

------
Alastair Aitchison
Beginning Spatial with SQL Server 2008
http://www.apress.com/book/view/9781430218296
Harry Bouckley-440138
Harry Bouckley-440138
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 12
Well, my flabber is absolutely gassed!
I assumed it had to be like that and I can assure you that I tried every combination I could. Obviously not Every combination, I assumed I would need double quotes for the first quotation.
I really appreciate your help, I can now continue with my life and apologise for all those remarks I made about the Microsoft implemtation of Spatial.

Thanks for that.
Harry
Anipaul
Anipaul
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13301 Visits: 1407
Excellent one...



lucassouzace
lucassouzace
Old Hand
Old Hand (369 reputation)Old Hand (369 reputation)Old Hand (369 reputation)Old Hand (369 reputation)Old Hand (369 reputation)Old Hand (369 reputation)Old Hand (369 reputation)Old Hand (369 reputation)

Group: General Forum Members
Points: 369 Visits: 79
Perfect, but i'm don't understand when you say: "then method Parse is simular STPointFromText" i'm don't understand too, How do say "SRID" im look, but i'm don't understand, thanks a lot! EXCELENTE TOPIC!
tom-1057534
tom-1057534
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 3
Part 1 and 2 were great. Where's part 3??
Bennie Haelen
Bennie Haelen
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 Visits: 63
I had an unexpected death in the family, which kept me occupied for quite a while. Look for the remaining articles in the series within the next couple of weeks
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