<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Spatial Ed&amp;#39;s blog</title><subtitle type="html">Information and news on spatial data support in Windows Azure SQL Database, SQL Server and environs...</subtitle><id>http://blogs.msdn.com/b/edkatibah/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/edkatibah/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2009-05-09T21:29:32Z</updated><entry><title>Setting Up A Delayed Sending Rule For Email In Microsoft Outlook</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2012/12/17/setting-up-a-delayed-sending-rule-for-email-in-microsoft-outlook.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2012/12/17/setting-up-a-delayed-sending-rule-for-email-in-microsoft-outlook.aspx</id><published>2012-12-18T01:45:59Z</published><updated>2012-12-18T01:45:59Z</updated><content type="html">&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/4113.Outlook2010_5F00_bL.png"&gt;&lt;img style="border: 0px currentColor;" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/4113.Outlook2010_5F00_bL.png" alt="" width="352" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Author: Ed Katibah, Microsoft SQLCAT&lt;br /&gt;&lt;br /&gt;Reviewer: Abdallah Fateen, Microsoft&lt;/p&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;A few weeks ago, a couple of us were in the hallway discussing email and the topic of recalling sent email came up.&amp;nbsp; After some discussion, a colleague, Chris Kurt suggested another approach &amp;ndash; implementing a delay in outgoing email, a.k.a. a delayed sending rule?&amp;nbsp; That sounded like it could be a great general purpose approach and subsequently became the basis for this blog post since I liked it so much.&lt;/p&gt;
&lt;p&gt;As a means of introducing this rule, how many times have you pressed the Send button on an email only to realize in the following moments that you wished to add (or delete) something on the email &amp;ndash; maybe you left somebody off of the To&amp;hellip; line who needed to be on it.&amp;nbsp; Or worse, you had second thoughts about sending the email at all.&amp;nbsp; Wouldn&amp;rsquo;t it be nice if the email were delayed for a few minutes before it was actually sent, allowing you time to be able to modify it (or delete it)?&amp;nbsp; The following tutorial steps you through how to set up such a rule in Microsoft Outlook, in this case Outlook 2010 (Version 14). The post reviewer, Abdallah, reports that the instructions presented in this post work with Outlook 2013, also.&lt;/p&gt;
&lt;h2&gt;Quick Start&lt;/h2&gt;
&lt;p&gt;If you have done this before and/or want just the basic&lt;br /&gt;steps to get started, here is a quick start guide:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A.&lt;/strong&gt; In Outlook, select &amp;ldquo;&lt;strong&gt;File&lt;/strong&gt;&amp;rdquo;, &amp;ldquo;&lt;strong&gt;Info&lt;/strong&gt;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;B.&lt;/strong&gt; On the &amp;ldquo;Account Information&amp;rdquo; screen, select &amp;ldquo;&lt;strong&gt;Manage Rules and Alerts&lt;/strong&gt;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C.&lt;/strong&gt; On the &amp;ldquo;Rules and Alerts&amp;rdquo; screen, select &amp;ldquo;&lt;strong&gt;New Rule&lt;/strong&gt;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;D.&lt;/strong&gt; On the "Rules Wizard" screen, go the "&lt;strong&gt;Start from blank rule&lt;/strong&gt;" section and select "&lt;strong&gt;Apply rule on messages I send&lt;/strong&gt;"&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;E.&lt;/strong&gt; On the next "Rules Wizard" screen, go to "&lt;strong&gt;Step 1: Select condition(s)&lt;/strong&gt;" and &lt;strong&gt;check "on this computer only"&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;F. &lt;/strong&gt;On the next "Rules Wizard" screen, go to the "&lt;strong&gt;Step 1: Select actions(s)&lt;/strong&gt;"&lt;br /&gt;section and...&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;check "&lt;strong&gt;defer delivery by a number of minutes&lt;/strong&gt;"&lt;/li&gt;
&lt;li&gt;select "&lt;strong&gt;a number of" minutes&lt;/strong&gt; hyperlink... under Step 2 on the screen&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;enter the number of minutes&lt;/strong&gt; to delay sending in the popup menu&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;G.&lt;/strong&gt; On the next "Rules Wizard" screen, go to the "&lt;strong&gt;Step 1: Select exceptions(s)&lt;/strong&gt;" section and...&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;check "&lt;strong&gt;except if the subject contains specific words&lt;/strong&gt;"&lt;/li&gt;
&lt;li&gt;select the "&lt;strong&gt;specific words" hyperlink in Step 2...&lt;/strong&gt;&amp;rdquo;&lt;/li&gt;
&lt;li&gt;enter the &lt;strong&gt;specific word(s) string&lt;/strong&gt; in the "Search Text" menu&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;H.&lt;/strong&gt; Enter the &lt;strong&gt;specific word or phrases string&lt;/strong&gt; in the "Search Text" menu on which to apply the delay exception&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I.&lt;/strong&gt; This step is a &lt;strong&gt;recap&lt;/strong&gt; of the last wizard screen, confirming the choices that you just made&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;J.&lt;/strong&gt; On the next "Rules Wizard" screen, you can &lt;strong&gt;name&lt;/strong&gt;, &lt;strong&gt;finalize&lt;/strong&gt; and &lt;strong&gt;review&lt;/strong&gt; the new rule in 3 easy steps&amp;hellip;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;K.&lt;/strong&gt; Accept the final notification screen and you are done.&lt;/p&gt;
&lt;h2&gt;Steps&lt;/h2&gt;
&lt;p&gt;Here are steps I employed to set up a rule to delay sending mail by 4 minutes.&amp;nbsp; I also added several key words, which when added (typically appended) to the subject line, instruct Outlook to bypass the delayed mail send rule and send immediately.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step A&lt;/strong&gt;: In Outlook, select &amp;ldquo;&lt;strong&gt;File&lt;/strong&gt;&amp;rdquo;, &amp;ldquo;&lt;strong&gt;Info&lt;/strong&gt;&amp;rdquo;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/8875.Image_5F00_2.png"&gt;&lt;img style="border: 0px currentColor;" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/8875.Image_5F00_2.png" alt="" width="198" /&gt;&lt;/a&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step B:&lt;/strong&gt; On the &amp;ldquo;Account Information&amp;rdquo; screen, select &amp;ldquo;&lt;strong&gt;Manage Rules and Alerts&lt;/strong&gt;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/7870.Image_5F00_3a.png"&gt;&lt;img style="border: 0px currentColor;" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/7870.Image_5F00_3a.png" alt="" width="657" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step C:&lt;/strong&gt; On the &amp;ldquo;Rules and Alerts&amp;rdquo; screen, select &amp;ldquo;&lt;strong&gt;New Rule&lt;/strong&gt;&amp;rdquo;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/3480.Image_5F00_4.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/3480.Image_5F00_4.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step D:&lt;/strong&gt; On the "Rules Wizard" screen, go the "&lt;strong&gt;Start from blank rule&lt;/strong&gt;" section and select "&lt;strong&gt;Apply rule on messages I send&lt;/strong&gt;"&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/3835.Image_5F00_6.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/3835.Image_5F00_6.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step E:&lt;/strong&gt; On the next "Rules Wizard" screen, go to "&lt;strong&gt;Step 1: Select condition(s)&lt;/strong&gt;" and &lt;strong&gt;check "on this computer only"&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/8765.Image_5F00_7.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/8765.Image_5F00_7.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step F:&lt;/strong&gt; On the next "Rules Wizard" screen, go to the "&lt;strong&gt;Step 1: Select actions(s)&lt;/strong&gt;" section and...&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;check "&lt;strong&gt;defer delivery by a number of minutes&lt;/strong&gt;"&lt;/li&gt;
&lt;li&gt;select "&lt;strong&gt;a number of" minutes&lt;/strong&gt; hyperlink... under Step 2 on the screen&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;enter the number of minutes&lt;/strong&gt; to delay sending in the popup menu&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;: 1 minute is the default.&amp;nbsp; I set my delay for 4 minutes as a personal preference.&amp;nbsp; Set your delay to however many minutes you would like.&amp;nbsp;You can always go back and modify the delay (or remove it altogether).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/1641.Image_5F00_8_2D00_9.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/1641.Image_5F00_8_2D00_9.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step G:&lt;/strong&gt; On the next "Rules Wizard" screen, go to the "&lt;strong&gt;Step 1: Select exceptions(s)&lt;/strong&gt;" section and...&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;check "&lt;strong&gt;except if the subject contains specific words&lt;/strong&gt;"&lt;/li&gt;
&lt;li&gt;select the "&lt;strong&gt;specific words" hyperlink in Step 2...&lt;/strong&gt;&amp;rdquo;&lt;/li&gt;
&lt;li&gt;enter the &lt;strong&gt;specific word(s) string&lt;/strong&gt; in the "Search Text" menu&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;: In this example, I used the keyword "&amp;lt;send&amp;gt;".&amp;nbsp; In the following examples, I added a couple of additional key words, used to bypass the sending delay.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/4786.Image_5F00_10_2D00_11.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/4786.Image_5F00_10_2D00_11.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step H.&lt;/strong&gt; Enter the &lt;strong&gt;specific word or phrases string&lt;/strong&gt; in the "Search Text" menu on which to apply the delay exception&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/1778.Image_5F00_12a.png"&gt;&lt;img style="border: 0px currentColor;" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/1778.Image_5F00_12a.png" alt="" width="520" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step I:&lt;/strong&gt; This step is a &lt;strong&gt;recap&lt;/strong&gt; of the last wizard screen, confirming the choices that you just made.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/3817.Image_5F00_13a.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/3817.Image_5F00_13a.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step J:&lt;/strong&gt; On the next "Rules Wizard" screen, you can &lt;strong&gt;name&lt;/strong&gt;, &lt;strong&gt;finalize&lt;/strong&gt; and &lt;strong&gt;review&lt;/strong&gt; the new rule in 3 easy steps&amp;hellip;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/2654.Image_5F00_14.png"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/2654.Image_5F00_14.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step K.&lt;/strong&gt; Accept the final notification screen and you are done.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/1261.Image_5F00_15.png"&gt;&lt;img style="border: 0px currentColor;" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-25/1261.Image_5F00_15.png" alt="" width="540" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10378871" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Rule" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Rule/" /><category term="Exception" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Exception/" /><category term="Send" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Send/" /><category term="Outlook" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Outlook/" /><category term="Email" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Email/" /><category term="Delayed" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Delayed/" /><category term="2010" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/2010/" /><category term="2013" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/2013/" /></entry><entry><title>Updated Spatial Features in the SQL Azure Q4 2011 Service Release</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/12/13/updated-spatial-features-in-the-sql-azure-q4-2011-service-release.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/12/13/updated-spatial-features-in-the-sql-azure-q4-2011-service-release.aspx</id><published>2011-12-13T22:37:21Z</published><updated>2011-12-13T22:37:21Z</updated><content type="html">&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;The Q2 2011 Service Release of SQL Azure introduced the updated spatial data platform from SQL Server 2012. SQL Server 2012 spatial features are being released in SQL Azure in increments, beginning with Q2 2011 Service Release. With the introduction of the Q4 2011 Service Release for SQL Azure, a new TechNet Wiki post&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;, &lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/updated-spatial-features-in-the-sql-azure-q4-2011-service-release.aspx" rel="nofollow" target="_blank"&gt;Updated Spatial Features in SQL Azure Q4 2011 Service Release&lt;/a&gt;, is now available, providing the definative guide to the new SQL Server 2012 spatial features making their appearance in SQL Azure.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;The Q4 2011 Service Relase enables the following spatial features relative to the Q2 2011 Service Release:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri;"&gt;Spatial aggregates (&lt;strong&gt;CollectionAggregate&lt;/strong&gt;(),&lt;strong&gt;ConvexHullAggregate&lt;/strong&gt;(), &lt;strong&gt;UnionAggregate&lt;/strong&gt;()), and &lt;strong&gt;geometry::EnvelopeAggregate&lt;/strong&gt;() now work correctly. &lt;strong&gt;Geography::EnvelopeAggregate&lt;/strong&gt; does not work because it returns a circular subtype which is not yet supported in SQL Azure (see the &lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/updated-spatial-features-in-the-sql-azure-q4-2011-service-release.aspx" target="_blank"&gt;post&lt;/a&gt; for more details). Additionally, the system view, &lt;strong&gt;sys.spatial_reference_systems&lt;/strong&gt;, previously missing from SQL Azure, is now available.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For more information on the new SQL Server 2012 spatial features, please see the TechNet Wiki: &lt;a href="http://sqlcat.com/sqlcat/b/whitepapers/archive/2011/08/08/new-spatial-features-in-sql-server-code-named-denali-community-technology-preview-3.aspx" target="_blank"&gt;New Spatial Features in SQL Server Code-Named "Denali" Community Technology Preview 3&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;- Ed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10247381" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /><category term="SQL Azure" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/SQL+Azure/" /><category term="SQL Server Code-Name &amp;quot;Denali&amp;quot;" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/SQL+Server+Code_2D00_Name+_2600_quot_3B00_Denali_2600_quot_3B00_/" /><category term="SQL Server 2012" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/SQL+Server+2012/" /><category term="Q4 2011 Service Release" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Q4+2011+Service+Release/" /><category term="Q4SR" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Q4SR/" /><category term="Q4 2011 SR" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Q4+2011+SR/" /></entry><entry><title>Potential Side-Effects of Improved Spatial Precision in SQL Server 2012 and the SQL Azure September 2011 Service Release</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/11/15/potential-side-effects-of-improved-spatial-precision-in-sql-server-2012-and-the-sql-azure-september-2011-service-release.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/11/15/potential-side-effects-of-improved-spatial-precision-in-sql-server-2012-and-the-sql-azure-september-2011-service-release.aspx</id><published>2011-11-15T23:07:14Z</published><updated>2011-11-15T23:07:14Z</updated><content type="html">&lt;p&gt;In Microsoft SQL Server 2012 (previously known as SQL Server Code-Name &amp;ldquo;Denali&amp;rdquo;), all constructions and relations are now done with 48 bits of precision, compared to 27 bits used in SQL Server 2008 and SQL Server 2008 R2. This can result in differences that range from how individual coordinates (vertices) in spatial objects appear (rounding) to how computational results are produced in different versions of the database server for certain spatial operations.&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: calibri;"&gt;Recently, SQL Azure has been upgraded in all data centers to incorporate the new SQL Server 2012 spatial library. This upgrade, known as the September 2011 Service Release, thus enables spatial operations in SQL Azure to be the computationally identical with SQL Server 2012.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: calibri;"&gt;Because of this new feature, results from spatial operations in SQL Azure September Refresh and SQL Server 2012 can differ from results produced in their respective prior versions. This&lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/5580.aspx" rel="nofollow"&gt; technical note&lt;/a&gt; reviews the effects of the precision change and assists in identifying potential migration issues..&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10237503" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /><category term="SQL Azure" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/SQL+Azure/" /><category term="SQL Server Code-Name &amp;quot;Denali&amp;quot;" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/SQL+Server+Code_2D00_Name+_2600_quot_3B00_Denali_2600_quot_3B00_/" /><category term="Persisted computed columns" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Persisted+computed+columns/" /><category term="Precision" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Precision/" /><category term="SQL Server 2012" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/SQL+Server+2012/" /></entry><entry><title>New Spatial Features in SQL Server Code-Named “Denali” Community Technology Preview 3</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/08/08/new-spatial-features-in-sql-server-code-named-denali-community-technology-preview-3.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/08/08/new-spatial-features-in-sql-server-code-named-denali-community-technology-preview-3.aspx</id><published>2011-08-08T18:53:53Z</published><updated>2011-08-08T18:53:53Z</updated><content type="html">&lt;p&gt;We have just released a new white paper, &lt;a href="http://sqlcat.com/whitepapers/archive/2011/08/08/new-spatial-features-in-sql-server-code-named-denali-community-technology-preview-3.aspx"&gt;New Spatial Features in SQL Server Code-Named “Denali”&lt;/a&gt;.&amp;#160; This white paper covers the spatial improvements added to both CTP1 and CTP3 and becomes the definitive spatial guide to this release of SQL Server.&lt;/p&gt;  &lt;p&gt;You can download the new server from this location: &lt;a href="https://www.microsoft.com/betaexperience/pd/SQLDCTP3CTA/enus/" target="_blank"&gt;Microsoft SQL Server code-named 'Denali' CTP3&lt;/a&gt; and try out the new spatial features.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10193770" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Spatial Support Coming to the SQL Server Entity Framework</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/06/23/spatial-support-coming-to-the-sql-server-entity-framework.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/06/23/spatial-support-coming-to-the-sql-server-entity-framework.aspx</id><published>2011-06-23T16:25:36Z</published><updated>2011-06-23T16:25:36Z</updated><content type="html">&lt;p&gt;Some of you may not have heard that spatial support is coming in the next version of the SQL Server Entity Framework. Here is the first paragraph from a post on this subject:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;“One of the highly-anticipated features coming in the next version of Entity Framework is Spatial support. The team has been hard at work designing a compelling story for Spatial, and we would love to get your feedback on it. In this post we will cover:&lt;/em&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;The basics of SQL Server’s spatial support &lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;Design goals &lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;Walkthrough of design: CLR types, Metadata, Usage, WCF Serialization, Limitations &lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;Questions (we want to hear from you!)&lt;/em&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;em&gt;This entry will not cover the tools experience as we want to focus on what is happening under the hood. We will blog about the tools design at a later time. For now, be sure that we plan on shipping Spatial with Tools support.”&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;You can read the full post here: &lt;a title="http://blogs.msdn.com/b/efdesign/archive/2011/05/04/spatial-types-in-the-entity-framework.aspx" href="http://blogs.msdn.com/b/efdesign/archive/2011/05/04/spatial-types-in-the-entity-framework.aspx"&gt;http://blogs.msdn.com/b/efdesign/archive/2011/05/04/spatial-types-in-the-entity-framework.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10178253" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Spatial Aggregates in SQL Server Denali</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/04/27/spatial-aggregates-in-sql-server-denali.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/04/27/spatial-aggregates-in-sql-server-denali.aspx</id><published>2011-04-27T21:20:38Z</published><updated>2011-04-27T21:20:38Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;SQL Server Code-named “Denali” is currently available as a Community Technology Preview (CTP).&amp;#160; Denali introduces 4 new aggregates to the the suite of spatial operators in SQL Server:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Union Aggregate&lt;/li&gt;    &lt;li&gt;Envelope Aggregate&lt;/li&gt;    &lt;li&gt;Collection Aggregate&lt;/li&gt;    &lt;li&gt;Convex Hull Aggregate&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All aggregates are implemented as static methods which work for either the Geography or the Geometry data types. As an example, consider the following geography aggregate:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Geography::UnionAggregate(geog)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;and its counterpart for geometry:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Geometry::UnionAggregate(geom)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The following introduces each aggregate with a short definition, a code sample and a visual illustrating what goes into the aggregate and what is returned. While aggregates are applicable to all classes of spatial data (points, linestrings, etc.) they are most effectively described and illustrated with polygons, which are used in the following discussion.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Union Aggregate&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Combines multiple spatial objects into a single spatial object, removing interior boundaries, where applicable.&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;SELECT &lt;font color="#ff0000"&gt;Geography::UnionAggregate(geog)&lt;/font&gt;       &lt;br /&gt;&amp;#160; &lt;/font&gt;&lt;font size="2" face="Courier New"&gt;FROM Counties      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font size="2" face="Courier New"&gt;WHERE name_1 = 'Washington';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/8865.image_5F00_38909B0E.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/0458.image_5F00_thumb_5F00_3958DB2B.png" width="640" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;strong&gt;Envelope Aggregate&lt;/strong&gt;&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;The unlike other aggregates, the Envelope Aggregate exhibits different behavior depending on whether is is applied to a geography or a geometry type.&amp;#160; For the geometry type, a “traditional” rectangular polygon is calculated which closely bounds the selected input objects.&amp;#160; For the geography type, a circular object is calculated which loosely bounds the selected input objects.&amp;#160; Furthermore, the circular object is defined using the new CurvePolygon feature.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Envelope Aggregate for the Geometry Type&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Returns a bounding rectangular polygon object, which encloses one or more spatial objects. &lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;SELECT &lt;font color="#ff0000"&gt;Geometry::EnvelopeAggregate(geom)&lt;/font&gt;       &lt;br /&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160; FROM Counties      &lt;br /&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; WHERE name_1 = 'Washington';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/0042.image_5F00_121E91F6.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/2273.image_5F00_thumb_5F00_31CD6BBE.png" width="640" height="130" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="2"&gt;Envelope Aggregate for the Geography Type&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Returns a bounding circular object as a CurvePolygon which encloses one or more spatial objects.&lt;/p&gt;    &lt;p&gt;&lt;font size="2" face="Courier New"&gt;SELECT &lt;font color="#ff0000"&gt;Geography::EnvelopeAggregate(geog&lt;/font&gt;).STCurveToLine()       &lt;br /&gt;&amp;#160; &lt;/font&gt;&lt;font size="2" face="Courier New"&gt;FROM Counties      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font size="2" face="Courier New"&gt;WHERE name_1 = 'Washington';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note the STCurveToLine() method in the sample code, above.&amp;#160; This new method is used to output spatial objects in a manner which older visualization systems can digest.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/6724.image_5F00_71975243.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/5734.image_5F00_thumb_5F00_6358D953.png" width="640" height="205" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Collection Aggregate&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Returns a geometry collection with one geometry part for each spatial object(s) in the selection set.&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;SELECT &lt;font color="#ff0000"&gt;Geography::CollectionAggregate(geog)&lt;/font&gt;       &lt;br /&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160; FROM Counties      &lt;br /&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; WHERE name_1 = 'Washington';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/6724.image_5F00_42D199A1.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/5734.image_5F00_thumb_5F00_56EAB62A.png" width="640" height="204" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="3"&gt;Convex Hull Aggregate&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Returns a convex hull polygon which encloses one or more spatial objects.&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;SELECT &lt;font color="#ff0000"&gt;Geography::ConvexHullAggregate(geog)&lt;/font&gt;       &lt;br /&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160; FROM Counties      &lt;br /&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&amp;#160;&amp;#160;&amp;#160; WHERE name_1 = 'Washington';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/8054.image_5F00_36637678.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/7701.image_5F00_thumb_5F00_2105C110.png" width="640" height="118" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1ea439c6-ef33-436a-a356-0cf9e30eaf26" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Denali" rel="tag"&gt;Denali&lt;/a&gt;,&lt;a href="http://technorati.com/tags/spatial" rel="tag"&gt;spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/aggregates" rel="tag"&gt;aggregates&lt;/a&gt;,&lt;a href="http://technorati.com/tags/union" rel="tag"&gt;union&lt;/a&gt;,&lt;a href="http://technorati.com/tags/envelope" rel="tag"&gt;envelope&lt;/a&gt;,&lt;a href="http://technorati.com/tags/collection" rel="tag"&gt;collection&lt;/a&gt;,&lt;a href="http://technorati.com/tags/convex+hull" rel="tag"&gt;convex hull&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10158819" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Spatial Support for Persisted Computed Columns In Denali CTP1</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/01/25/spatial-support-for-persisted-computed-columns-in-denali-ctp1.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/01/25/spatial-support-for-persisted-computed-columns-in-denali-ctp1.aspx</id><published>2011-01-25T22:55:21Z</published><updated>2011-01-25T22:55:21Z</updated><content type="html">&lt;p&gt;A few weeks ago, in the whitepaper, &lt;a href="http://sqlcat.com/whitepapers/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-community-technology-preview-1.aspx" target="_blank"&gt;New Spatial Features in SQL Server Code-Named “Denali” Community Technology Preview 1&lt;/a&gt;, new spatial support for persisted computed columns was presented.&amp;#160; This post will elaborate on this new feature, describing how it is different from prior support in SQL Server 2008.&lt;/p&gt;  &lt;p&gt;In SQL Server 2008 you could create a column in a table defined by a spatial method.&amp;#160; For instance, you could create a column to store and persist the area of a polygon using the STArea() method, for instance, as long as that method did not return a spatial type (Geometry or Geography):&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;CREATE TABLE LOCATION (      &lt;br /&gt;&amp;#160; ID INT PRIMARY KEY,&amp;#160; &lt;br /&gt;&amp;#160; GEOM GEOMETRY,       &lt;br /&gt;&amp;#160; &lt;font style="background-color: #ffffff"&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&lt;font color="#ff0000"&gt;AREA AS GEOM.STArea() PERSISTED&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;&lt;font style="background-color: #ffffff" color="#ff0000"&gt;        &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2" face="Courier New"&gt;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Note that the computed column, AREA, will be of type FLOAT.&lt;/p&gt;  &lt;p&gt;In SQL Server Denali CTP1, this functionality is supported and augmented with the ability to persist a computed spatial column (Geometry or Geography) in the table definition.&amp;#160; For example, lets say that you wanted to define the centroid of the polygon in the GEOM column in the table DDL.&amp;#160; In Denali CTP1 (but not in SQL Server 2008) you can define this as follows:&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Courier New"&gt;CREATE TABLE LOCATION (      &lt;br /&gt;&amp;#160; ID INT PRIMARY KEY,       &lt;br /&gt;&amp;#160; GEOM GEOMETRY,       &lt;br /&gt;&amp;#160; AREA AS GEOM.STArea() PERSISTED,       &lt;br /&gt;&amp;#160; &lt;font color="#ff0000"&gt;CENTROID AS GEOM.STCentroid() PERSISTED        &lt;br /&gt;&lt;/font&gt;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Note that the computed column, CENTROID, will be of type GEOMETRY.&lt;/p&gt;  &lt;p&gt;Here is how this table looks in SSMS:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/6102.image_5F00_5B04FB90.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/0247.image_5F00_thumb_5F00_4130C561.png" width="348" height="138" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:cdb76c73-7b4f-40dd-930e-bb847ebe4482" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/spatial" rel="tag"&gt;spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Denali" rel="tag"&gt;Denali&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CTP1" rel="tag"&gt;CTP1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/computed" rel="tag"&gt;computed&lt;/a&gt;,&lt;a href="http://technorati.com/tags/persisted" rel="tag"&gt;persisted&lt;/a&gt;,&lt;a href="http://technorati.com/tags/column" rel="tag"&gt;column&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10120255" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Database Compatibility Levels: Getting Existing Spatial Databases Ready For Denali</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2011/01/17/database-compatibility-levels-getting-existing-spatial-databases-ready-for-denali.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2011/01/17/database-compatibility-levels-getting-existing-spatial-databases-ready-for-denali.aspx</id><published>2011-01-17T16:52:54Z</published><updated>2011-01-17T16:52:54Z</updated><content type="html">&lt;p&gt;With the availability of the new &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9" target="_blank"&gt;SQL Server code-named “Denali” CTP1&lt;/a&gt; release, some of you will be moving existing SQL Server 2008 databases into the new server.&amp;#160; In order to enable the new spatial features in Denali, you will need to update the database compatibility level for existing SQL Server 2008 databases.&amp;#160; For Denali, the compatibility level is 110 and can be set with the following T-SQL:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;--Set database compatibility level to SQL Server Code-Named &amp;quot;Denali&amp;quot;      &lt;br /&gt;ALTER DATABASE &amp;lt;&lt;em&gt;database name&amp;gt;&lt;/em&gt;       &lt;br /&gt;SET COMPATIBILITY_LEVEL = 110;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;You can get information on the compatibility level of all databases in a given SQL Server instance with the following stored procedure:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_helpdb&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;For more information on database compatibility levels please see: &lt;a href="http://msdn.microsoft.com/en-us/library/bb510680.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb510680.aspx&lt;/a&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8f4daa67-bcb2-4a11-a6c1-fba375741026" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/compatibility+level" rel="tag"&gt;compatibility level&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/spatial" rel="tag"&gt;spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Denali" rel="tag"&gt;Denali&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10116652" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>New Functions Added To The SQL Server Spatial Tools CodePlex Project</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2010/12/30/new-functions-added-to-the-sql-server-spatial-tools-codeplex-project.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2010/12/30/new-functions-added-to-the-sql-server-spatial-tools-codeplex-project.aspx</id><published>2010-12-30T17:00:32Z</published><updated>2010-12-30T17:00:32Z</updated><content type="html">&lt;p&gt;Two new functions have been added to the &lt;a href="http://sqlspatialtools.codeplex.com/" target="_blank"&gt;SQL Server Spatial Tools CodePlex Project&lt;/a&gt;:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;FilterArtifactsGeography&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;FilterArtifactsGeometry&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;These new functions, as the names imply, are designed to remove unwanted components from spatial objects.&amp;#160; For instance, consider the output from the Reduce() method on a Geography object which results in a GeometryCollection consisting of a MultiPolygon and many Point components.&amp;#160; The &lt;strong&gt;FilterArtifactsGeography&lt;/strong&gt; function can be used to remove the Point components and return only the MultiPolygon.&amp;#160; &lt;/p&gt;  &lt;p&gt;As one would imagine, these functions also allow the removal of LineStrings and Empty geometries. Arguably, however, the most interesting feature of the new functions is their ability to remove Polygons – specifically very thin polygons (often called “slivers”).&amp;#160; Slivers can creep into spatial objects from a variety of ways, most commonly from union operations on polygons which do not precisely match each others adjoining edges.&amp;#160; The polygon filtering feature of these new functions employs a simple but very effective algorithm which allows a fair degree of control over which Polygon components are removed from the input object.&amp;#160; Here is the formula:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;ring.STArea &amp;lt; ringTolerance * ring.STLength&lt;/p&gt;    &lt;p&gt;&lt;em&gt;where: ringTolerance is a value supplied by the user&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ring.STLength is calculated by the function&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; and is the circumference of the ring&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In practice, this allows very thin polygon rings (slivers) to be detected and removed while leaving more typically shaped polygon rings alone.&amp;#160; The presumption is, of course, that slivers are undesirable but non-sliver rings are desirable.&lt;/p&gt;  &lt;p&gt;Here is the more formal description of the &lt;strong&gt;FilterArtifactsGeography()&lt;/strong&gt; function:&lt;/p&gt;  &lt;p&gt;&lt;u&gt;SqlGeography &lt;b&gt;FilterArtifactsGeography&lt;/b&gt;(SqlGeography geography, bool filterEmptyShapes, bool filterPoints, double lineStringTolerance, double ringTolerance)&lt;/u&gt;&lt;/p&gt; &lt;u&gt;&lt;/u&gt;  &lt;p&gt;   &lt;br /&gt;Selectively filter unwanted shapes from input geography, with the following arguments:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;geography SQLGeography – Input geography object.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;filterEmptyShapes boolean – A value of 1 will remove all empty shapes while a value of 0 will not remove any empty shapes.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;filterPoints Boolean – A value of 1 will remove all point/multipoint shapes while a value of 0 will not remove any.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;lineSTringTolerance double – Remove all linestring/multilinestring shapes shorter than the provided tolerance. A value of 0 will not remove any linestring/multilinestring shapes.      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;ringTolerance double – Remove all polygon rings thinner than provided tolerance (e.g. ring.STArea&amp;lt; ringTolerance * ring.STLength). A value of 0 will not remove any rings. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The &lt;strong&gt;FilterArtifactsGeometry&lt;/strong&gt; function is identical in description with the substitution of geometry for geography. Both functions will always return the simplest OGC construction possible.&lt;/p&gt;  &lt;p&gt;Here is a pseudo-code example of the &lt;strong&gt;FilterArtifactsGeography&lt;/strong&gt; function in use:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;FilterArtifactsGeography(@g, 1, 1, 4, 2)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here is an example using the &lt;strong&gt;FilterArtifactsGeometry&lt;/strong&gt; function:&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; DECLARE @g GEOMETRY&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; SET @g = GEOMETRY::STGeomFromText(&lt;span style="color: #006080"&gt;'GEOMETRYCOLLECTION (&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;                                      LINESTRING (51 51, 99 99), &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;                                      MULTILINESTRING ((52 50, 70 50),(80 50, 100 50)),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;                                      POINT (50 50),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;                                      POINT EMPTY,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;                                      MULTIPOINT ((30 30),(31 31), (32 32)),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;                                      POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;                                               (10 80, 20 80, 20 90, 10 90, 10 80),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;                                               (10 10, 90 10, 90 11, 10 11, 10 10)))'&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;                                    ,4326)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt; SELECT @g&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/7268.image_5F00_23E0189F.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/2084.image_5F00_thumb_5F00_229B7FC0.png" width="470" height="473" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the resulting object after using the FilterArtifactsGeometry() function to remove empty components, Points/MultiPoints, LineStrings/MultiLineStrings and thin polygon rings:&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; DECLARE @g GEOMETRY&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; SET @g = GEOMETRY::STGeomFromText(&lt;span style="color: #006080"&gt;'GEOMETRYCOLLECTION (&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;                                      LINESTRING (51 51, 99 99), &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;                                      MULTILINESTRING ((52 50, 70 50),(80 50, 100 50)),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;                                      POINT (50 50),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;                                      POINT EMPTY,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;                                      MULTIPOINT ((30 30),(31 31), (32 32)),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;                                      POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;                                               (10 80, 20 80, 20 90, 10 90, 10 80),&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;                                               (10 10, 90 10, 90 11, 10 11, 10 10)))'&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;                                    ,4326)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt; SELECT dbo.FilterArtifactsGeometry(@g,1,1,200,1.1)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/2072.image_5F00_09337C86.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/1884.image_5F00_thumb_5F00_56CFA906.png" width="471" height="472" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;POLYGON ((0 0, 100 0, 100 100, 0 100, 0 0), (10 80, 20 80, 20 90, 10 90, 10 80))&lt;/p&gt;

&lt;p&gt;&lt;font color="#ff0000"&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;: The &lt;a href="http://sqlspatialtools.codeplex.com/" target="_blank"&gt;current SQL Server Spatial Tools CodePlex Project&lt;/a&gt; is designed for use with SQL Server 2008 (including R2).&amp;#160; Some functions in this project will not perform correctly in &lt;a href="http://blogs.msdn.com/b/edkatibah/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-ctp1.aspx?wa=wsignin1.0" target="_blank"&gt;Denali CTP1&lt;/a&gt;, including the two functions described in this post.&amp;#160; A new version of this project will be created which will be Denali-specific.&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a721e664-0685-41a8-8daa-f8afa74e3290" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/spatial" rel="tag"&gt;spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CodePlex" rel="tag"&gt;CodePlex&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial+Tools" rel="tag"&gt;Spatial Tools&lt;/a&gt;,&lt;a href="http://technorati.com/tags/artifacts" rel="tag"&gt;artifacts&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10110347" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>FME Webinar: Practical Techniques for Loading Data into SQL Server</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2010/12/09/fme-webinar-practical-techniques-for-loading-data-into-sql-server.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2010/12/09/fme-webinar-practical-techniques-for-loading-data-into-sql-server.aspx</id><published>2010-12-09T19:40:43Z</published><updated>2010-12-09T19:40:43Z</updated><content type="html">&lt;p&gt;One of the most often asked questions about SQL Server Spatial is “How do I load data into the spatial types?”. Safe Software has long provided solutions for this dilemma with their excellent ETL tool, Feature Manipulation Engine (FME).&amp;#160; On December 14th, Safe will be presenting an FME Webinar entitled “Practical Techniques for Loading Data into SQL Server”.&amp;#160; This webinar will cover such topics as:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Support for multiple spatial columns in a table&lt;/li&gt;    &lt;li&gt;Loading spatial data into SQL Azure Spatial&lt;/li&gt;    &lt;li&gt;The new, low cost, FME Desktop SQL Server Data Loading Edition &lt;/li&gt;    &lt;li&gt;The FME Extension for SSIS&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I would encourage anyone with an interest in this topic to register at &lt;a href="http://fme.safe.com/forms/SQLServerWebinar"&gt;http://fme.safe.com/forms/SQLServerWebinar&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Additionally, there is another page, &lt;a title="http://www.safe.com/c/load-data-into-sqlserver.php" href="http://www.safe.com/c/load-data-into-sqlserver.php"&gt;http://www.safe.com/c/load-data-into-sqlserver.php&lt;/a&gt;, which includes links to an overview movie as well as links to the webinar.&lt;/p&gt;  &lt;p&gt;Lastly, you can get more information on FME solutions for SQL Server on Safe’s &lt;a href="http://www.safe.com/solutions/database/SQLserver.php" target="_blank"&gt;SOLUTIONS FOR MICROSOFT SQL SERVER USERS&lt;/a&gt; page.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10102818" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>A Short Discussion On The ShortestLineTo() Method</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2010/11/19/a-short-discussion-on-the-shortestlineto-method.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2010/11/19/a-short-discussion-on-the-shortestlineto-method.aspx</id><published>2010-11-19T20:03:32Z</published><updated>2010-11-19T20:03:32Z</updated><content type="html">&lt;p&gt;In a recent post to the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/cb094fb8-07ba-4219-8d3d-572874c271b5"&gt;SQL Server Spatial Forum&lt;/a&gt;, the subject of finding the closest point from one geometry to another resurfaced. While this was a difficult problem with SQL Server 2008, the new &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9"&gt;“Denali” CTP&lt;/a&gt; has introduced a method, ShortestLineTo(), which provides a solution to this problem. &lt;/p&gt;  &lt;p&gt;Taking the geometries provided in the forum post by elangeo on Nov 16, 2010, @h and @g, I created a new geometry, @sl which contains the “shortest line” between the two geometries:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @h GEOMETRY = 'POINT(175346.325596772 202579.692494631)';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @g GEOMETRY = 'POLYGON((175373.37654079497 202663.47566268593, 175309.02370874584 202626.29556666315, 175328.32617276162 202595.99009463936, 175328.33046075702 202595.99284664169, 175335.22780476511 202600.4390546456, 175335.27100476623 202600.37697464228, 175335.33071676642 202600.29115064442, 175342.50012476742 202604.9433106482, 175343.06434877217 202605.3093906492, 175355.01686077565 202585.1888146326, 175355.22690878063 202584.8352146335, 175346.57487677038 202579.83649462834, 175350.90825277567 202572.54171062633, 175351.08706877381 202572.240654625, 175346.8919967711 202569.81697462127, 175345.81129277498 202569.19259062409, 175345.50646077097 202569.01646262407, 175352.43746877462 202558.13460661471, 175378.08418879658 202517.86843058839, 175378.47298879176 202517.2579985857, 175387.97513280064 202521.08609458804, 175392.46217280626 202523.75739059225, 175415.91702082008 202537.72103860229, 175429.48124483228 202545.79636660591, 175439.01698883623 202552.97799861059, 175438.9791008383 202553.04180661216, 175425.85634882748 202575.13236662746, 175373.37654079497 202663.47566268593), (175387.31574080139 202542.21063860506, 175387.92713280022 202542.56340660527,175385.82249280065 202546.25569460541, 175392.09526080638 202549.76961461082, 175391.75484480709 202550.37588660792, 175400.52566081286 202555.39905461296, 175402.95503681153 202551.16513460875, 175403.52956481278 202551.49115061015, 175408.33698881418 202543.07399860397, 175392.2850208059 202533.85300659761, 175387.31574080139 202542.21063860506))';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @sl GEOMETRY = @h.ShortestLineTo(@g);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is an illustration of how the geometries appear (note that I have buffered the point, @h, to make it more visible and located it with a red arrow).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/2313.clip_5F00_image001_5F00_6FD16C1E.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/3480.clip_5F00_image001_5F00_thumb_5F00_0F1412F2.png" width="436" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If I zoom in on the point, you can see the new “shortest-line-to” linestring:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/7608.image_5F00_71E03D58.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/5148.image_5F00_thumb_5F00_1C4C6E76.png" width="411" height="415" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If the resulting linestring is displayed as Well-known Text (WKT), you can observe that the ShortestLineTo() method returns two coordinates in the “from, to” order. In this case, from the point @h, to the polygon @g:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @sl.STAsText();      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;--Result: LINESTRING      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;-- (175346.325596772 202579.692494631, “from” point      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;-- 175346.57487677038 202579.83649462834) “to” point&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Thus, the second coordinate (“to” point), 175346.57487677038 202579.83649462834, is the nearest point on the polygon @g from the point @h. If you always contstruct your queries this fashion, you can reliably use the following “method” to retrieve the “closest point”:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @h.ShortestLineTo(@g).STPointN(2);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It should be noted that the ShortestLineTo() method does NOT “snap” between the nearest vertices on the input objects. This can be illustrated with the following simple example:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @c GEOMETRY = 'CIRCULARSTRING(1.5 1, 1.6 1.1, 1.5 2)';      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;DECLARE @g GEOMETRY = 'POLYGON((2.2 1, 3.2 1, 3.2 2, 2.2 2, 2.2 1))';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @g      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @c.ShortestLineTo(@g)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To emphasize this point (no pun intended), I’ve drawn in the defining vertices on the following illustration:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/4863.clip_5F00_image003_5F00_0DCF7A13.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/6136.clip_5F00_image003_5F00_thumb_5F00_2254C991.png" width="524" height="289" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The resulting points on the shortest-line-to linestring are unique and not part of the input object definitions:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @c.ShortestLineTo(@g).ToString();      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;--Result: LINESTRING (1.740312423743285 1.5, 2.2 1.5)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The careful reader will wonder how I drew the circularstring in the above illustration since circular arcs are not supported in the Spatial results tab in SSMS currently. To do this, I converted the circularstring @c into a linestring using the new STCurveToLine() method, as follows:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @c GEOMETRY = 'CIRCULARSTRING(1.5 1, 1.6 1.1, 1.5 2)';      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;DECLARE @s GEOMETRY = @c.STCurveToLine();      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;DECLARE @g GEOMETRY = 'POLYGON((2.2 1, 3.2 1, 3.2 2, 2.2 2, 2.2 1))';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @s      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @g      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @c.ShortestLineTo(@g)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If there are many solutions to the closest point between two geometries, the ShortestLineTo() method will pick one of them in an unpredictable way. Consider the following two polygons whose nearest points to each other result in multiple solutions:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @g1 GEOMETRY = 'POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))';      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;DECLARE @g2 GEOMETRY = 'POLYGON((2.2 1, 3.2 1, 3.2 2, 2.2 2, 2.2 1))';&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @g1      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @g2      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @g1.ShortestLineTo(@g2)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/0172.clip_5F00_image004_5F00_73FB43E3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/3731.clip_5F00_image004_5F00_thumb_5F00_5A9340A9.png" width="640" height="299" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Lastly, if the distance between the two spatial objects being compared is 0 then ShortestLineTo() will return an empty geometry.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @g1 GEOMETRY = 'POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))';      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;DECLARE @g2 GEOMETRY = 'POLYGON((2 1, 3 1, 3 2, 2 2, 2 1))';      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;DECLARE @sl GEOMETRY = @g1.ShortestLineTo(@g2);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @g1      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @g2      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;UNION ALL      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT @sl&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/2248.clip_5F00_image005_5F00_7A421A71.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="clip_image005" border="0" alt="clip_image005" src="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-99-25-metablogapi/6038.clip_5F00_image005_5F00_thumb_5F00_6720EDC5.png" width="581" height="297" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @g1.ShortestLineTo(@g2).ToString();      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;--Result: LINESTRING EMPTY&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To learn about other new spatial features in the “Denali” CTP1 release, please see the post: &lt;a href="http://blogs.msdn.com/b/edkatibah/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-ctp1.aspx"&gt;http://blogs.msdn.com/b/edkatibah/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-ctp1.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:81ad56a9-eb57-4bad-bed7-d9408907770d" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Technorati+Tags%3a+Spatial" rel="tag"&gt;Technorati Tags: Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Denali" rel="tag"&gt;Denali&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CTP1" rel="tag"&gt;CTP1&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ShortestLineTo" rel="tag"&gt;ShortestLineTo&lt;/a&gt;,&lt;a href="http://technorati.com/tags/STCurveToLine" rel="tag"&gt;STCurveToLine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Nearest+Point" rel="tag"&gt;Nearest Point&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Closest+Point" rel="tag"&gt;Closest Point&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10093979" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>New Spatial Features in SQL Server Code-Named “Denali” CTP1</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-ctp1.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-ctp1.aspx</id><published>2010-11-09T17:44:39Z</published><updated>2010-11-09T17:44:39Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;We have just released a white paper, &lt;a href="http://sqlcat.com/whitepapers/archive/2010/11/09/new-spatial-features-in-sql-server-code-named-denali-community-technology-preview-1.aspx" target="_blank"&gt;New Spatial Features in SQL Server Code-Named “Denali” Community Technology Preview 1&lt;/a&gt;&lt;strong&gt;&lt;em&gt;&lt;/em&gt;&lt;/strong&gt;, as your definitive guide to the spatial improvements in this release of SQL Server. &lt;/p&gt;  &lt;p&gt;Of course, you can’t take advantage of the new spatial features without the new server. You can now download the new server, &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9" target="_blank"&gt;Microsoft SQL Server code-named 'Denali' - Community Technology Preview 1 (CTP1)&lt;/a&gt;, today.&lt;/p&gt;  &lt;p&gt;Also, don’t forget that the serialization format for the spatial types has been updated in &lt;a href="http://download.microsoft.com/download/7/9/3/79326E29-1E2E-45EE-AA73-74043587B17D/[MS-SSCLRT].pdf"&gt;Microsoft SQL Server CLR Types Serialization Formats [MS-SSCLRT]&lt;/a&gt; for those of you who need to know even more.&lt;/p&gt;  &lt;p&gt;Let us know how you like the new spatial features.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10088300" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>Loading ANSS Earthquake Data Into SQL Server 2008</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2010/04/20/loading-anss-earthquake-data-into-sql-server-2008.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2010/04/20/loading-anss-earthquake-data-into-sql-server-2008.aspx</id><published>2010-04-20T17:49:09Z</published><updated>2010-04-20T17:49:09Z</updated><content type="html">&lt;p&gt;The &lt;a href="http://earthquake.usgs.gov/monitoring/anss/"&gt;Advanced National Seismic System&lt;/a&gt; (ANSS) maintains a comprehensive catalog of worldwide seismic events (typically earthquakes) which is a good source of spatial data for SQL Server 2008.&amp;#160; The ANSS Composite Catalog (formerly called the CNSS Earthquake Catalog) provides a search capability which allows the download of seismic events, from 1898 to present, using various search terms. In this post I will cover the following topics:&lt;/p&gt;  &lt;li&gt;Download ANSS seismic data &lt;/li&gt;  &lt;li&gt;Prepare the downloaded ANSS data &lt;/li&gt;  &lt;li&gt;Create a database table for the ANSS data &lt;/li&gt;  &lt;li&gt;Load the ANSS data &lt;/li&gt;  &lt;li&gt;Add, update and index the spatial data column &lt;/li&gt;  &lt;li&gt;Sample spatial queries on the ANSS data    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;h5&gt;DOWNLOAD ANSS SEISMIC DATA&lt;/h5&gt;    &lt;p&gt;It should be noted that the ANSS catalog contains a huge amount of data which should be carefully subsetted in order to avoid asking for too much information and unnecessarily tying up valuable computing resources attempting to service the request.&amp;#160; &lt;/p&gt;    &lt;p&gt;For this exercise, I have chosen to download a small subset of the available data. To start the download process, let’s go to the &lt;a href="http://www.ncedc.org/anss/catalog-search.html"&gt;catalog search page&lt;/a&gt;.&lt;/p&gt;    &lt;p&gt;Under the “Select earthquake catalog” section make sure that the “ANSS composite catalog (1898-present)” is selected (this is the only choice, currently).&amp;#160; Then select the radio button for “Catalog in CSV format”.&amp;#160; This will format the output data as comma separated values.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_9.png" width="570" height="162" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Next, go to the “Select earthquake parameters” section.&amp;#160; In this example, I want all events from January 1, 2000 forward, so I set the Start date,time to 1 second before midnight on the day before (1999/12/31/,23:59:59).&amp;#160; Since no “End date, time” was specified, the query will return the latest events.&amp;#160; Likewise with the other fields which are unset (events with all magnitudes and all depths will be returned since they have not been set).&amp;#160; The region specified by the Min/Max Latitudes/Longitudes will return the area covering all of the States of California and Nevada. Lastly, for Event Types:, I selected “All Events”.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_6.png" width="574" height="385" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that you can specify additional search parameters including a polygon within which to search.&amp;#160; It is interesting to note that the ANSS documentation states that &lt;em&gt;“[This] polygon must NOT cross the -180/180 degree longitude boundary, since the definition of the polygonal region becomes ambiguous”&lt;/em&gt;. Once this data is in the SQL Server Server GEOGRAPHY data type, such queries are easily supported.&lt;/p&gt;    &lt;p&gt;Lastly, in the “Select output mechanism”, choose the &amp;quot;Send output to an anonymous FTP file…” radio button.&amp;#160; I’ve set a rather high Line limit on output (500,000 records) since I expect a large number of events to be returned.&amp;#160; When ready, select the “Submit request” button.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_36.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_17.png" width="569" height="188" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;When your search is completed, you will receive a response in your web browser similar to the following:&lt;/p&gt;    &lt;p&gt;Your search parameters are: &lt;/p&gt;    &lt;p&gt;----------------------------------------------------------------------------------------------------------------&lt;/p&gt;    &lt;ul&gt;     &lt;p&gt;Your search parameters are: &lt;/p&gt;      &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; * catalog=ANSS        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * start_time=1999/12/31,23:59:59         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * end_time=2010/04/14,22:27:47         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * minimum_latitude=31.910759         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * maximum_latitude=42.192383         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * minimum_longitude=-124.755360         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * maximum_longitude=-113.17570         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * event_type=A &lt;/p&gt;      &lt;p&gt;Output has been placed in anonymous ftp.        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; host:&amp;#160; www.ncedc.org         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; file:&amp;#160; /outgoing/userdata/web/catsearch.15725         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; URL:&amp;#160;&amp;#160; &lt;a href="ftp://www.ncedc.org/outgoing/userdata/web/catsearch.15725"&gt;ftp://www.ncedc.org/outgoing/userdata/web/catsearch.15725&lt;/a&gt;         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Size:&amp;#160; 454847 lines (34187332 bytes)         &lt;br /&gt;File will be automatically deleted in 2 days.&lt;/p&gt;   &lt;/ul&gt;    &lt;pre&gt;----------------------------------------------------------------------------------------------------------------&lt;/pre&gt;

  &lt;p&gt;Note that the size entry returned a value (454,847 ) which is smaller than the Line limit on output - a value of 500,000.&amp;#160; This indicates that we have retrieved all of the desired events.&lt;/p&gt;

  &lt;p&gt;To retrieve the output file (in this case called “catsearch.15725”) use your favorite ftp tool.&lt;/p&gt;

  &lt;p&gt;&amp;#160;&lt;/p&gt;

  &lt;h5&gt;PREPARE THE DOWNLOADED ANSS DATA&lt;/h5&gt;

  &lt;p&gt;With file containing the selected events downloaded, the first thing I like to do is to rename the file to indicate its type, in this case a “csv”.&amp;#160; So, the file “catsearch.15725” was renamed to “catsearch.15725.csv”.&amp;#160; I also like to save the search parameters associated with the file, so I created a file, “README_catsearch.15725.txt” and saved the search parameters from the web page.&amp;#160; Here is a summary of the workflow, so far:&lt;/p&gt;

  &lt;blockquote&gt;
    &lt;p&gt;a. &lt;strong&gt;Rename the catsearch.15725 file to catsearch.15725.csv&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;b. [optional] &lt;strong&gt;Create a text file, README_catsearch.15725.txt&lt;/strong&gt;, to store the search parameter metadata.&lt;/p&gt;
  &lt;/blockquote&gt;

  &lt;p&gt;The ANSS downloaded data is now formatted as a&amp;#160; comma-separated, UTF-8 encoded text file. Each record is terminated with newline character ('\n').&amp;#160; SQL Server 2008 does not support UTF-8, expecting such data to be in UTF-16 encoding with each record delimited with a carriage return, newline combination ('\r\n').&amp;#160; Additionally, it needs a Byte Order Marker (BOM) at the beginning of the file.&amp;#160;&amp;#160; For this exercise, I chose to use the Windows text editor &lt;a href="http://www.ultraedit.com/"&gt;UltraEdit Professional&lt;/a&gt; to perform the conversion. Here is the workflow I used with UltraEdit:&lt;/p&gt;

  &lt;blockquote&gt;
    &lt;p&gt;c. &lt;strong&gt;Open the catsearch.15725 .csv file in UltraEdit&lt;/strong&gt;. &lt;/p&gt;
  &lt;/blockquote&gt;

  &lt;blockquote&gt;
    &lt;p&gt;Click the “No” button when asked if you want to convert to DOS format:&lt;/p&gt;
  &lt;/blockquote&gt;

  &lt;blockquote&gt;
    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_30.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_14.png" width="455" height="127" /&gt;&lt;/a&gt; &lt;/p&gt;
  &lt;/blockquote&gt;

  &lt;blockquote&gt;
    &lt;p&gt;d. &lt;strong&gt;Choose File –&amp;gt; Save As&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;e. &lt;strong&gt;Set File name: to “catsearch.15725.utf16.csv”&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;f. &lt;strong&gt;Set Save as type: to&amp;#160; All Files, (*.*)&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;g. &lt;strong&gt;Set Line Terminator: to DOS Terminators – CR/LF&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;h. &lt;strong&gt;Set Format: to UTF-16&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;Here are how steps e – h are shown in the Save As dialog box:&lt;/p&gt;

    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_34.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_16.png" width="457" height="206" /&gt;&lt;/a&gt; &lt;/p&gt;

    &lt;p&gt;i. &lt;strong&gt;Choose Save&lt;/strong&gt;&lt;/p&gt;
  &lt;/blockquote&gt;

  &lt;p&gt;&lt;em&gt;&lt;strong&gt;ULTRAEDIT NOTE ON LARGE FILE HANDLING:&lt;/strong&gt;&amp;#160; When files sizes get very large (several million records typically), it is useful to configure UltraEdit appropriately prior to editing.&amp;#160; You may find more information on how to perform such a configuration here: &lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/large_file_handling.html"&gt;&lt;em&gt;http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/large_file_handling.html&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;&lt;strong&gt;DATA NOTE:&lt;/strong&gt;&amp;#160; I found an occasional anomaly* in the ANSS data which will cause input rows to fail to be inserted into SQL Server.&amp;#160; Additionally, the technique used to load this data, BULK INSERT, fails to correctly write these rows out to the specified ERRORFILE* &lt;font color="#ff0000"&gt;(see Update, below)&lt;/font&gt;.&amp;#160; Because of this, I recommend that you locate and fix these anomalies prior to data loading.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;Specifically, there are instances in the DATETIME field of the input data where at least one of the components has a value of “60” in the time string.&amp;#160;&amp;#160; Here is an example:&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_10.png" width="678" height="88" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;p&gt;&lt;em&gt;SQL Server will not accept this value and rejects the row during insert. To fix this particular problem (shown in the example, above), in which the seconds component is set to 60, it is necessary to increment the minutes component by 1 and set the seconds component to 00.&amp;#160; Since there were only 5 such occurrences out of 454,000+ records, I went ahead and made the changes in UltraEdit directly (using the search string “:60”).&amp;#160; I will look into other techniques for handling these errors and possibly publish my findings in a future blog post.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;Additionally, I found another issue with the data (1 single record) which had a value of 24 for the hours time component.&amp;#160; This record was rejected by BULK INSERT with the following error message:&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;Msg 4864, Level 16, State 1, Line 1 
      &lt;br /&gt;Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 67082, column 1 (DateTime).&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_42.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_11.png" width="682" height="87" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;You can search for the string “ 24:” to locate such data.&amp;#160; Note that “fixing” this data entails reving the associated data to the next day.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;----------------------------------------------------------------------------------------------------------------&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;* I talked with &lt;a href="http://www.sqlskills.com/blogs/bobb/"&gt;Bob Beauchemin&lt;/a&gt; about both the ANSS data time anomalies and the truncated BULK INSERT ERRORFILE entries.&amp;#160; Bob was unable to reproduce either issue:&amp;#160; the ANSS data he downloaded (which contained the data I downloaded) did not have any of the time faults that I found and there was not problem with the ERRORFILE records.&amp;#160; Bob was using SQL Server 2008 R2 November CTP as I was also, so I’ll have to do a bit more research on this issue.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;----------------------------------------------------------------------------------------------------------------&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;font color="#ff0000"&gt;Update:&lt;/font&gt; &lt;em&gt;I found the source of my confusion regarding BULK INSERT supposedly dropping the date component of the datetime string in the error file.&amp;#160; When I opened the error file in Excel (it’s a .csv file, so it’s naturally associated with Excel), here is what I get:&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/clip_image001_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/clip_image001_thumb.jpg" width="562" height="116" /&gt;&lt;/a&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;Notice that the date component is dropped (and so is the hour component of the time string, btw).&amp;#160; Also notice that Excel attempts to fix the time data but does fully complete the job.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;When I open the same error file in a text editor, I get the expected error output:&lt;/em&gt;&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;2000/09/13 06:26:60.00,36.5225,-115.2721,2.88,1.20,ML,6,,,0.13,NN, 
2001/10/08 24:00:07.62,37.1190,-113.3735,1.16,2.59,Mc,9,180,49,0.65,UU, 
2002/07/10 01:40:60.00,37.4114,-117.1425,0.00,0.88,ML,13,,,0.08,NN, 
2004/09/21 04:16:60.00,37.9981,-118.6963,6.57,0.18,Mb,7,109,4,0.06,NN,1463 
2005/09/25 17:20:60.00,39.4529,-119.8317,3.06,0.36,ML,8,123,3,0.10,NN,1665 
2005/11/07 06:25:60.00,39.2235,-120.0856,8.82,0.37,ML,12,85,9,0.07,NN,1685&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;&lt;em&gt;So, confusion over – there is nothing wrong with BULK INSERT error files.&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;----------------------------------------------------------------------------------------------------------------&lt;/em&gt;&lt;/p&gt;

  &lt;h5&gt;&amp;#160;&lt;/h5&gt;

  &lt;h5&gt;CREATE A DATABASE TABLE FOR THE ANSS DATA&lt;/h5&gt;

  &lt;p&gt;Here is the T-SQL&amp;#160; to create a table called Earthquakes...&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; Earthquakes( 
  DateTime  DATETIME &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  Latitude  &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,  
  Longitude &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  &lt;span class="kwrd"&gt;Depth&lt;/span&gt;     &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  Magnitude &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  MagType   &lt;span class="kwrd"&gt;VARCHAR&lt;/span&gt;(12) &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,  
  NbStation &lt;span class="kwrd"&gt;INT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  Gap       &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  Distance  &lt;span class="kwrd"&gt;INT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  RMS       &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  Source    &lt;span class="kwrd"&gt;VARCHAR&lt;/span&gt;(12) &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, 
  EventID   &lt;span class="kwrd"&gt;VARCHAR&lt;/span&gt;(12) &lt;span class="kwrd"&gt;NULL&lt;/span&gt; 
); 
GO&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;For information on the column definitions, please see &lt;a title="http://www.ncedc.org/ftp/pub/doc/cat1/catlist.1" href="http://www.ncedc.org/ftp/pub/doc/cat1/catlist.1"&gt;http://www.ncedc.org/ftp/pub/doc/cat1/catlist.1&lt;/a&gt;. &lt;/p&gt;

  &lt;p&gt;Note that the EventID column appears to be of type INT – that is until you come across a value such as the one below:&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_8.png" width="574" height="78" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;p&gt;Consequently, I had no choice but to make this a character field in the CREATE TABLE DDL.&lt;/p&gt;

  &lt;p&gt;&amp;#160;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;h5&gt;LOAD THE ANSS DATA&lt;/h5&gt;

  &lt;p&gt;To load the data, you can use the following T-SQL for the BULK INSERT command:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;BULK&lt;/span&gt; INSERT Earthquakes 
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; &lt;span class="str"&gt;'C:\Data\ANSS\catsearch.15725.utf16.csv'&lt;/span&gt; 
    &lt;span class="kwrd"&gt;WITH&lt;/span&gt;( 
      DATAFILETYPE = &lt;span class="str"&gt;'widechar'&lt;/span&gt;, 
      FIRSTROW = 2, 
      FIELDTERMINATOR = &lt;span class="str"&gt;','&lt;/span&gt;, 
      ROWTERMINATOR = &lt;span class="str"&gt;'\n'&lt;/span&gt;, 
      MAXERRORS = 50, 
      ERRORFILE = &lt;span class="str"&gt;'C:\Data\ANSS\catsearch.15725.utf16.error.csv'&lt;/span&gt; 
    ); 
&lt;span class="kwrd"&gt;GO&lt;/span&gt; 
--(454846 &lt;span class="kwrd"&gt;row&lt;/span&gt;(s) affected)&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;The DATAFILETYPE is set to ‘widechar’ to support the UTF16 data format.&amp;#160; The first record in the file contains the names of the fields, thus we need to start the data load with the second record (FIRSTROW = 2).&amp;#160; Since this is a comma-separated value file, the FIELDTERMINATOR must be set to ‘,’.&amp;#160; The row terminator is ‘\r\n’ but BULK INSERT demands that ROWTERMINATOR be set to ‘\n’ (go figure).&amp;#160; I’ve set MAXERRORS to 50 from the default of 10 and specified an ERRORFILE to hold errant rows.&lt;/p&gt;

  &lt;p&gt;&amp;#160;&lt;/p&gt;

  &lt;h5&gt;ADD, UPDATE AND INDEX THE SPATIAL DATA COLUMN&lt;/h5&gt;

  &lt;p&gt;In order to accommodate SQL Server 2008 spatial data, I added a column of type GEOGRAPHY (named Location) to the Earthquakes table as follows:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;ALTER&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; Earthquakes 
  &lt;span class="kwrd"&gt;ADD&lt;/span&gt; Location GEOGRAPHY &lt;span class="kwrd"&gt;NULL&lt;/span&gt;; 
&lt;span class="kwrd"&gt;GO&lt;/span&gt; &lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;With the Location column added to the table, I can now update the Location column using the Point constructor static method:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;UPDATE&lt;/span&gt; Earthquakes 
  &lt;span class="kwrd"&gt;SET&lt;/span&gt; Location = GEOGRAPHY::Point(latitude,longitude,4326); 
&lt;span class="kwrd"&gt;GO&lt;/span&gt; &lt;br /&gt;-- (454846 &lt;span class="kwrd"&gt;row&lt;/span&gt;(s) affected) (00:00:16)&lt;/pre&gt;
&lt;/li&gt;

&lt;li&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;The value of 4326 in the Point constructor is the spatial reference identifier (SRID).&amp;#160; This SRID indicates that the geographic coordinate system is WGS84.&amp;#160; While not specified in the ANSS on-line documentation, this a reasonable assumption for global data such as this.&lt;/p&gt;

  &lt;p&gt;In order to create a spatial index, you must have a primary key on the table.&amp;#160; The following T-SQL creates an identity column, ID, as a primary key: 
    &lt;br /&gt;&amp;#160; &lt;br /&gt;&lt;font size="2" face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;ALTER&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; Earthquakes 
  &lt;span class="kwrd"&gt;ADD&lt;/span&gt; ID BIGINT &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt; 
    &lt;span class="kwrd"&gt;CONSTRAINT&lt;/span&gt; ID_PK &lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt; &lt;span class="kwrd"&gt;KEY&lt;/span&gt;(ID); 
GO&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;With that done, a spatial index can now be created on the Location column:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; SPATIAL &lt;span class="kwrd"&gt;INDEX&lt;/span&gt; location_hhhh1_sidx  
  &lt;span class="kwrd"&gt;ON&lt;/span&gt; Earthquakes(Location) 
    &lt;span class="kwrd"&gt;USING&lt;/span&gt; GEOGRAPHY_GRID 
    &lt;span class="kwrd"&gt;WITH&lt;/span&gt; ( 
      GRIDS = (HIGH, HIGH, HIGH, HIGH), 
      CELLS_PER_OBJECT = 1, 
      PAD_INDEX = &lt;span class="kwrd"&gt;ON&lt;/span&gt; 
    ); 
&lt;span class="kwrd"&gt;GO&lt;/span&gt; 
--Results: 00:00:35 seconds&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;Since this is point data, setting the GRIDS parameters all to HIGH will typically yield the best performance.&lt;/p&gt;

  &lt;p&gt;&amp;#160;&lt;/p&gt;

  &lt;h5&gt;SAMPLE SPATIAL QUERYIES ON THE ANSS DATA&lt;/h5&gt;

  &lt;p&gt;Query 1: Plot all of the earthquakes with a magnitude &amp;gt; 3.&amp;#160; Highlight the large earthquakes by creating a buffer polygon around their epicenter. In this case, the earthquake data was drawn over the county polygons for&amp;#160; States of California and Nevada.&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Location &lt;span class="kwrd"&gt;FROM&lt;/span&gt; Earthquakes &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; Magnitude &amp;gt; 3 
&lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Location.STBuffer(50000) &lt;span class="kwrd"&gt;FROM&lt;/span&gt; Earthquakes &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; Magnitude &amp;gt; 7 
&lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Geog &lt;span class="kwrd"&gt;FROM&lt;/span&gt; Counties 
  &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; NAME_1 = &lt;span class="str"&gt;'California'&lt;/span&gt; &lt;span class="kwrd"&gt;or&lt;/span&gt; NAME_1 = &lt;span class="str"&gt;'Nevada'&lt;/span&gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_40.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_19.png" width="404" height="488" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;p&gt;Here is the same data plotted on a Bing Maps background using the Report Builder in the SQL Server 2008 R2 November CTP:&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_4.png" width="546" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;Note that the 7.2 magnitude earthquake (the largest in this dataset), which occurred below Mexicali on April 4, 2010, is displayed with a white star symbol.&lt;/p&gt;

  &lt;p&gt;Query 2. For the next query exercise, I wanted to take a look at the earthquake distribution relative to my house in Contra Costa County, California.&amp;#160; &lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @p GEOGRAPHY = GEOGRAPHY::Point(38.12345,-121.12345,4326); 
&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @g GEOGRAPHY = 
  (&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Geog &lt;span class="kwrd"&gt;FROM&lt;/span&gt; Counties 
     &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; NAME_1 = &lt;span class="str"&gt;'California'&lt;/span&gt; &lt;span class="kwrd"&gt;and&lt;/span&gt; NAME_2 = &lt;span class="str"&gt;'Contra Costa'&lt;/span&gt;); 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; Location, DateTime, Magnitude, &lt;span class="kwrd"&gt;Depth&lt;/span&gt; 
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; Earthquakes 
    &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; Location.STIntersects(@g) = 1 
&lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @g, &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, &lt;span class="kwrd"&gt;NULL&lt;/span&gt; -– Contra Costa Country polygon 
&lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @p.STBuffer(750),&lt;span class="kwrd"&gt;NULL&lt;/span&gt;, &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, &lt;span class="kwrd"&gt;NULL&lt;/span&gt; -– make my house location visible 
&lt;span class="kwrd"&gt;UNION&lt;/span&gt; &lt;span class="kwrd"&gt;ALL&lt;/span&gt; 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; @p,&lt;span class="kwrd"&gt;NULL&lt;/span&gt;, &lt;span class="kwrd"&gt;NULL&lt;/span&gt;, &lt;span class="kwrd"&gt;NULL&lt;/span&gt;; -– plot the location &lt;span class="kwrd"&gt;of&lt;/span&gt; my house &lt;span class="kwrd"&gt;as&lt;/span&gt; a point 
-- (2925 &lt;span class="kwrd"&gt;row&lt;/span&gt;(s) affected) (00:00:04)&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_2.png" width="552" height="309" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;p&gt;Note that my house is nicely remote from most earthquake activity.&amp;#160; Was this by clever analysis or dumb luck?&lt;/p&gt;

  &lt;p&gt;Here is the same query in visualized in SSRS map.&amp;#160; If you look closely, you can see my house location as a small purple triangle with the label “Spatial Ed” underneath the symbol.&lt;/p&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_3.png" width="644" height="465" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;Query 3.&amp;#160; Let’s perform a query that’s a little more intensive spatially.&amp;#160; Let’s find the 50 earthquakes with a magnitude greater than 2.0 nearest to my house.&amp;#160; Then, let’s find the nearest earthquake with a magnitude greater than 3.0.&lt;/p&gt;

  &lt;p&gt;The technique to do a nearest neighbor query in SQL Server 2008 relies upon a numbers table, so let’s create that table:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;-------------------------------------------------------&lt;span class="rem"&gt;-- &lt;/span&gt;
--&lt;span class="kwrd"&gt;Create&lt;/span&gt; Numbers &lt;span class="kwrd"&gt;Table&lt;/span&gt; 
-------------------------------------------------------&lt;span class="rem"&gt;-- &lt;/span&gt;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 100000 &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt;,1,1) &lt;span class="kwrd"&gt;AS&lt;/span&gt; n &lt;span class="kwrd"&gt;INTO&lt;/span&gt; numbers 
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; master..spt_values a, master..spt_values b 
&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;UNIQUE&lt;/span&gt; &lt;span class="kwrd"&gt;CLUSTERED&lt;/span&gt; &lt;span class="kwrd"&gt;INDEX&lt;/span&gt; idx_1 &lt;span class="kwrd"&gt;ON&lt;/span&gt; numbers(n); 
GO&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;Now I can query for the top 50 earthquakes nearest to my home’s location with a magnitude greater than or equal to 2.0:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- Ed’s house (not the real location ;-) &lt;/span&gt;&lt;span class="kwrd"&gt;&lt;br /&gt;DECLARE&lt;/span&gt; @&lt;span class="kwrd"&gt;input&lt;/span&gt; GEOGRAPHY = GEOGRAPHY::Point(38.12345,-121.12345,4326); &lt;br /&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @&lt;span class="kwrd"&gt;start&lt;/span&gt; &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; = 10000; &lt;span class="rem"&gt;-- meters &lt;/span&gt;
&lt;span class="kwrd"&gt;WITH&lt;/span&gt; NearestNeighbor &lt;span class="kwrd"&gt;AS&lt;/span&gt; 
( 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 50 &lt;span class="kwrd"&gt;WITH&lt;/span&gt; TIES *, b.Location.STDistance(@&lt;span class="kwrd"&gt;input&lt;/span&gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; dist 
   &lt;span class="kwrd"&gt;FROM&lt;/span&gt; NUMBERS n 
     &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; Earthquakes b &lt;span class="kwrd"&gt;WITH&lt;/span&gt;(&lt;span class="kwrd"&gt;INDEX&lt;/span&gt;(location_hhhh1_sidx)) 
       &lt;span class="kwrd"&gt;ON&lt;/span&gt; b.Location.STDistance(@&lt;span class="kwrd"&gt;input&lt;/span&gt;) &amp;lt; @&lt;span class="kwrd"&gt;start&lt;/span&gt;*POWER(&lt;span class="kwrd"&gt;CAST&lt;/span&gt;(2 &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt;),n.n) 
     &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; n &amp;lt;= 20 &lt;span class="kwrd"&gt;AND&lt;/span&gt; Magnitude &amp;gt;= 2.0 
     &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; n 
) 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 50 location, DateTime, magnitude, dist 
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; NearestNeighbor 
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; n, dist&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;Here is the query to find the nearest earthquake to my location with a magnitude greater or equal to 3.0:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @&lt;span class="kwrd"&gt;input&lt;/span&gt; GEOGRAPHY = GEOGRAPHY::Point(38.12345,-121.12345,4326); &lt;br /&gt;&lt;span class="kwrd"&gt;DECLARE&lt;/span&gt; @&lt;span class="kwrd"&gt;start&lt;/span&gt; &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt; = 10000; &lt;span class="rem"&gt;-- meters &lt;/span&gt;
&lt;span class="kwrd"&gt;WITH&lt;/span&gt; NearestNeighbor &lt;span class="kwrd"&gt;AS&lt;/span&gt; 
( 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; &lt;span class="kwrd"&gt;TOP&lt;/span&gt; 1 &lt;span class="kwrd"&gt;WITH&lt;/span&gt; TIES *, b.Location.STDistance(@&lt;span class="kwrd"&gt;input&lt;/span&gt;) &lt;span class="kwrd"&gt;AS&lt;/span&gt; dist 
   &lt;span class="kwrd"&gt;FROM&lt;/span&gt; NUMBERS n 
     &lt;span class="kwrd"&gt;JOIN&lt;/span&gt; Earthquakes b &lt;span class="kwrd"&gt;WITH&lt;/span&gt;(&lt;span class="kwrd"&gt;INDEX&lt;/span&gt;(location_hhhh1_sidx)) 
       &lt;span class="kwrd"&gt;ON&lt;/span&gt; b.Location.STDistance(@&lt;span class="kwrd"&gt;input&lt;/span&gt;) &amp;lt; @&lt;span class="kwrd"&gt;start&lt;/span&gt;*POWER(&lt;span class="kwrd"&gt;CAST&lt;/span&gt;(2 &lt;span class="kwrd"&gt;AS&lt;/span&gt; &lt;span class="kwrd"&gt;FLOAT&lt;/span&gt;),n.n) 
     &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; n &amp;lt;= 20 &lt;span class="kwrd"&gt;AND&lt;/span&gt; Magnitude &amp;gt;= 3.0 
     &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; n 
) 
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; 1 location, DateTime, magnitude, dist 
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; NearestNeighbor 
&lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; n, dist&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;p&gt;This returns the following:&lt;/p&gt;

  &lt;blockquote&gt;
    &lt;pre class="csharpcode"&gt;Location:  POINT(-122.1113 37.8965) 
DateTime:  2007-03-02 04:40:00.750    
Magnitude: 4.2          
Distance:  4084.75488358986&lt;/pre&gt;
    &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

  &lt;p&gt;&lt;font size="2"&gt;The map, below, is symbolized as follows:&lt;/font&gt;&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;&lt;font size="2"&gt;Yellow triangle (in center of map): Spatial Ed’s house&lt;/font&gt; &lt;/li&gt;

    &lt;li&gt;&lt;font size="2"&gt;Yellow circle (near top of map): earthquake &amp;gt;= 3.0 nearest house location&lt;/font&gt; &lt;/li&gt;

    &lt;li&gt;&lt;font size="2"&gt;Red circles: 50 nearest earthquakes &amp;gt;= 2.0 nearest house location&lt;/font&gt; &lt;/li&gt;
  &lt;/ul&gt;

  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_24.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingANSSEarthquakeDataIntoSQLServer20_906F/image_thumb_7.png" width="644" height="422" /&gt;&lt;/a&gt; &lt;/p&gt;

  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:97265faf-a824-4031-9098-d9172305ee32" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/R2" rel="tag"&gt;R2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial+Data" rel="tag"&gt;Spatial Data&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ANSS" rel="tag"&gt;ANSS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CNSS" rel="tag"&gt;CNSS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/seismic" rel="tag"&gt;seismic&lt;/a&gt;,&lt;a href="http://technorati.com/tags/earthquake" rel="tag"&gt;earthquake&lt;/a&gt;,&lt;a href="http://technorati.com/tags/bulk+insert" rel="tag"&gt;bulk insert&lt;/a&gt;,&lt;a href="http://technorati.com/tags/T-SQL" rel="tag"&gt;T-SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Reporting+Services" rel="tag"&gt;Reporting Services&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Report+Builder" rel="tag"&gt;Report Builder&lt;/a&gt;,&lt;a href="http://technorati.com/tags/nearest+neighbor" rel="tag"&gt;nearest neighbor&lt;/a&gt;,&lt;a href="http://technorati.com/tags/UltraEdit" rel="tag"&gt;UltraEdit&lt;/a&gt;,&lt;a href="http://technorati.com/tags/numbers+table" rel="tag"&gt;numbers table&lt;/a&gt;&lt;/div&gt;

  &lt;p&gt;&lt;/p&gt;
&lt;/li&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9999358" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>Spatial Data Support Coming To SQL Azure</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2010/03/21/spatial-data-support-coming-to-sql-azure.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2010/03/21/spatial-data-support-coming-to-sql-azure.aspx</id><published>2010-03-21T23:49:24Z</published><updated>2010-03-21T23:49:24Z</updated><content type="html">&lt;p&gt;Last Wednesday (March 17th), Dave Robinson of the SQL Azure Team announced upcoming support for spatial data in SQL Azure.&amp;#160; You can view the announcement at the MIX Conference in the video of Dave’s presentation, &lt;a href="http://live.visitmix.com/MIX10/Sessions/SVC07"&gt;Building Web Applications with Microsoft SQL Azure&lt;/a&gt; (go to 18:40 on the timeline for the start of the spatial data portion of his talk).&lt;/p&gt;  &lt;p&gt;Dave reports that spatial will be available in the SU3 release of SQL Azure, tentatively scheduled for this June.&lt;/p&gt;  &lt;p&gt;I’ve been using SQL Azure with spatial support for a couple of weeks now and it works just like the spatial data support in SQL Server 2008 – same spatial data types, spatial methods and spatial indexes.&amp;#160; It works in SQL Server Management Studio just like you would expect (see below).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/SpatialDataSupportComingToSQLAzure_EC7D/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/SpatialDataSupportComingToSQLAzure_EC7D/image_thumb.png" width="551" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Query performance is excellent.&amp;#160; In the above example, the query executed in under a second against a table containing over 1.8 million rows (GeoNames points-of-interest for the United States).&lt;/p&gt;  &lt;p&gt;The only real differences that I have found between SQL Server and SQL Azure are true for all data:&lt;/p&gt;  &lt;p&gt;1. You need to have a clustered index on the table you are inserting data into.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Note that this can be satisfied by a primary key, which in turn is a requirement for creating a spatial index. You can view this a good thing for spatial ;-)&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;2. You may need to break your data loads up into chunks to prevent the connection to SQL Azure from timing out.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;If you are loading data from an existing SQL Server database, a great tool is the &lt;/em&gt;&lt;a href="http://sqlazuremw.codeplex.com/"&gt;&lt;em&gt;SQL Azure Migration Wizard&lt;/em&gt;&lt;/a&gt;&lt;em&gt; found on CodePlex.&amp;#160; It currently offers some minor complaints about spatial data when you run it (spatial indexes in particular) but does the right thing anyway.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If I’m not mistaken, SQL Azure will become the first pure cloud database to offer spatial support.&amp;#160; It will be interesting to watch how this new feature is put to use…&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4aae0f9c-29e4-4788-aadb-80f89fbe6d9f" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial+Data" rel="tag"&gt;Spatial Data&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Azure" rel="tag"&gt;SQL Azure&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Migration+Assistant" rel="tag"&gt;Migration Assistant&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9982667" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>Inside Microsoft SQL Server 2008: T-SQL Programming – Source Code and Spatial Data for Chapter 14</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/12/22/inside-microsoft-sql-server-2008-t-sql-programming-source-code-and-spatial-data-for-chapter-14.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/12/22/inside-microsoft-sql-server-2008-t-sql-programming-source-code-and-spatial-data-for-chapter-14.aspx</id><published>2009-12-23T01:14:04Z</published><updated>2009-12-23T01:14:04Z</updated><content type="html">&lt;p&gt;In the &lt;a href="http://blogs.msdn.com/edkatibah/archive/2009/12/17/inside-microsoft-sql-sever-2008-t-sql-programming-chapter-14-spatial-data.aspx"&gt;previous post&lt;/a&gt;, the content for Chapter 14, Spatial Data, was presented.&amp;#160; This post will discuss the sample code and the spatial data associated with the chapter.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;SOURCE CODE&lt;/strong&gt;.&amp;#160; The Source Code for Chapter 14 - Spatial Data is located in the zip file:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://downloads.solidq.com/insidetsql/TSQLProgramming20090901.zip"&gt;TSQLProgramming20090901.zip&lt;/a&gt; (457,765 B)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Within the zip file the source code is contained in the file: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Chapter 14 – Spatial Data.sql (156,256 B)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;SPATIAL DATA&lt;/strong&gt;. The spatial data for the chapter contains a selection of US-based data and provides the basis for many of the code examples used in the chapter.&lt;/p&gt;  &lt;p&gt;For downloading ease, the spatial data is archived as a single zip file and which is subsequently split into 7 segments.&lt;/p&gt;  &lt;p&gt;This is the view of the &lt;a href="http://downloads.solidq.com/insidetsql/"&gt;download site&lt;/a&gt; at Solid Quality Mentors:&lt;/p&gt;  &lt;pre&gt;   Tuesday, December 08, 2009  5:50 PM        45456 &lt;a href="http://downloads.solidq.com/insidetsql/ReadMeZip.rtf"&gt;ReadMeZip.rtf&lt;/a&gt;&lt;br /&gt;  Thursday, November 05, 2009  3:37 AM    100431872 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.z01"&gt;Sample_Data.z01&lt;/a&gt;&lt;br /&gt;  Thursday, November 05, 2009  6:43 PM    100431872 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.z02"&gt;Sample_Data.z02&lt;/a&gt;&lt;br /&gt;  Thursday, November 05, 2009  8:02 PM    100431872 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.z03"&gt;Sample_Data.z03&lt;/a&gt;&lt;br /&gt;  Thursday, November 05, 2009  9:10 PM    100431872 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.z04"&gt;Sample_Data.z04&lt;/a&gt;&lt;br /&gt;  Thursday, November 05, 2009 10:17 PM    100431872 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.z05"&gt;Sample_Data.z05&lt;/a&gt;&lt;br /&gt;    Friday, November 06, 2009  8:26 AM    100431872 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.z06"&gt;Sample_Data.z06&lt;/a&gt;&lt;br /&gt;    Friday, November 06, 2009  1:20 PM     89577422 &lt;a href="http://downloads.solidq.com/insidetsql/Sample_Data.zip"&gt;Sample_Data.zip&lt;/a&gt;&lt;br /&gt; Wednesday, October 21,  2009 10:35 AM       457765 TSQLProgramming20090901.zip&lt;/pre&gt;

&lt;p&gt;After downloading all 7 of the Sample_Data.xxx files, you open the split zip files by opening the file with the .zip extension (Sample_Data.zip). &lt;em&gt;Don't try to open any of the files with the numbered extensions - WinZip (and other &amp;quot;zip&amp;quot; programs) won't recognize them as zip files.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;After restoring the Sample_data.zip archive, the resulting Sample Data folder contains the companion data for Chapter 14, Spatial Data. This folder is comprised of the following files:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;BTS_shapefile.zip &lt;/li&gt;

  &lt;li&gt;Data_Dictionary.rtf &lt;/li&gt;

  &lt;li&gt;Readme_First.rtf &lt;/li&gt;

  &lt;li&gt;Sample_Data_Content_Attribution.rtf &lt;/li&gt;

  &lt;li&gt;SAMPLE_TEXT.txt &lt;/li&gt;

  &lt;li&gt;Sample_USA.zip &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;BTS_shapefile.zip&lt;/b&gt;. [44,382 MB compressed] This the zip archive contains the source shapefile for Highways table in the Sample_USA database. &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;
&lt;b&gt;Data_Dictionary.rtf&lt;/b&gt;. This document contains the metadata describing the tables contained in the Sample_USA database. 

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Sample_Data_Content_Attribution.rtf&lt;/b&gt;. This document describes the sources of data provided with this distribution and the license agreements, where applicable. 

  &lt;br /&gt;

  &lt;br /&gt;&lt;b&gt;SAMPLE_TEXT.txt&lt;/b&gt;. This file contains tab-delimited data, including latitude and longitude, points-of-interest data, and is used as the basis for an example in Chapter 14. This data is derived from the &lt;a href="http://www.geonames.org/"&gt;GeoNames&lt;/a&gt; database.&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Sample_USA.zip&lt;/b&gt;. [631,582 KB compressed, 2.33GB uncompressed] Contains the SQL Server 2008 backup file, Sample_USA.bak, containing the tables and registered assemblies used as the basis for coding examples in Chapter 14. The backup file is intended to be used to restore the database, Sample_USA to a SQL Server 2008 instance.&lt;/p&gt;

&lt;p&gt;&amp;#160; Tables:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;dbo.CensusBlockGroups &lt;i&gt;– [polygon] US Census Block Groups&lt;/i&gt; &lt;em&gt;(212,942 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.Counties &lt;em&gt;– [polygon] US&lt;/em&gt; &lt;em&gt;Counties (3,146 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.CountiesFIPSCodes – &lt;i&gt;[tabular] US Federal Information Processing Codes for States, Counties&lt;/i&gt; &lt;em&gt;(3,141 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.GeoNames &lt;i&gt;– [point] GeoNames points-of-interest for US&lt;/i&gt; &lt;em&gt;(1,892,290 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.GeoNamesFeatures &lt;i&gt;– [tabular] – Codes for GeoNames features&lt;/i&gt; &lt;em&gt;(664 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.Highways &lt;i&gt;– [linestring] US Highways&lt;/i&gt; &lt;em&gt;(8,362 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.Nums &lt;i&gt;– [tabular] Numbers table&lt;/i&gt; &lt;em&gt;(20 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.States &lt;i&gt;– [polygon] – US States&lt;/i&gt; &lt;em&gt;(51 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.StatesFIPSCodes &lt;i&gt;– [tabular] US Federal Information Processing Codes for States&lt;/i&gt; &lt;em&gt;(51 rows)&lt;/em&gt; &lt;/li&gt;

  &lt;li&gt;dbo.ZIPCodes &lt;i&gt;– [polygon] – US Census-based ZIPCodes&lt;/i&gt; &lt;em&gt;(49,146 rows)&lt;/em&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160; Programmability:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&amp;#160; Assemblies registered to the database:&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;SQLSpatialTools – CodePlex SQL Server Spatial Tools project assembly &lt;/li&gt;

    &lt;li&gt;transformer – Assembly created in the Chapter 14 code examples &lt;/li&gt;

    &lt;li&gt;UnionAgg – Assembly created in the Chapter 14 code examples &lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;The following images illustrate the spatial content for the tables with spatial columns in the Sample_USA database.&amp;#160; The State of Nevada is used for the examples, but all data extends to the full USA.&lt;/p&gt;

&lt;p&gt;CensusBlockGroups table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Counties table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Geonames table*&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_thumb_2.png" width="179" height="244" /&gt;&lt;/a&gt; &lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_thumb_4.png" width="179" height="244" /&gt;&lt;/a&gt; &lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_13.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_thumb_5.png" width="177" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Highways table*&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; States table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ZIPCodes table&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_15.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_thumb_6.png" width="179" height="244" /&gt;&lt;/a&gt; &lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_17.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_thumb_7.png" width="177" height="244" /&gt;&lt;/a&gt; &lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_19.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/InsideMicrosoftSQLServer2008TSQLProgramm_CD90/image_thumb_8.png" width="178" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;* the data in these images are clipped to less than 5000 objects, the limit of Management Studio’s spatial display capabilities and is unioned with the outline of the State of Nevada for context.&lt;/em&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9940337" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>Inside Microsoft SQL Sever 2008: T-SQL Programming, Chapter 14, Spatial Data</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/12/17/inside-microsoft-sql-sever-2008-t-sql-programming-chapter-14-spatial-data.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/12/17/inside-microsoft-sql-sever-2008-t-sql-programming-chapter-14-spatial-data.aspx</id><published>2009-12-18T00:55:37Z</published><updated>2009-12-18T00:55:37Z</updated><content type="html">&lt;p&gt;In a shameless bit of self-promotion, I’d like to call attention to the new book, Inside Microsoft SQL Server 2008: T-SQL Programming (Microsoft Press). &lt;/p&gt;  &lt;p&gt;&lt;img src="http://www.solidq.com/insidetsql/images/T-SQL%20Programming%202008.jpg" /&gt;&lt;/p&gt;  &lt;p&gt;You can get further information on the book at &lt;a href="http://www.solidq.com/insidetsql/books/insidetsql2008/"&gt;Itzik’s blog&lt;/a&gt; or by going to &lt;a href="http://www.microsoft.com/learning/en/us/Book.aspx?ID=12805&amp;amp;locale=en-us"&gt;Microsoft Press&lt;/a&gt;, but I wanted highlight Chapter 14 on spatial data in this post.&amp;#160;&amp;#160; &lt;a href="http://blogs.msdn.com/isaac/"&gt;Isaac Kunen&lt;/a&gt; and I collaborated on this chapter and together turned out 81 pages of action packed reading… ;-).&amp;#160; While this chapter is designed to be a stand alone treatise on SQL Server Spatial, it is also a nice compliment to Alastair Aitchison’s book, &lt;a href="http://beginningspatial.com/"&gt;Beginning Spatial with SQL Server 2008&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;There are three main components to this chapter:&lt;/p&gt;  &lt;p&gt;1. The chapter content, presented here by the table of contents&lt;/p&gt;  &lt;p&gt;2. Source code for the chapter examples&lt;/p&gt;  &lt;p&gt;3. Sample spatial data for use with the source code&lt;/p&gt;  &lt;p&gt;Here is the table of contents for the chapter:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="4"&gt;&lt;strong&gt;Chapter 14&lt;/strong&gt;&lt;/font&gt;       &lt;br /&gt;&amp;#160; &lt;font size="3"&gt;&lt;strong&gt;Spatial Data&lt;/strong&gt;&lt;/font&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;&lt;font size="2"&gt;Introduction to Spatial Data&lt;/font&gt;&lt;/strong&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;&lt;font size="2"&gt;Basic Spatial Data Concepts&lt;/font&gt;&lt;/strong&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Vector Data and the OGC Simple Features Type Model       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Planar and Geographic Coordinates       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Spatial Reference Identifiers       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Standards       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Working on the Ellipsoid       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Data&lt;/strong&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Common Forms of Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Finding Spatial Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Loading Spatial Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sample Spatial Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Getting Started with Spatial Data&lt;/strong&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Creating a Table with a Spatial Column       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Well-Known Text       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Constructing Spatial Objects from Strings and Inserting into a Table       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Basic Object Interaction Tests       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Basic Spatial Operations       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Intersecting Spatial Objects       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Union of Spatial Objects       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Generalization of Spatial Objects       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Proximity Queries       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Distance between Spatial Objects       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Spatial Buffers       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Comparing Spatial Buffers and Distance-Based Calculations to Test      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Proximity       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; The GEOGRAPHY Type       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; The Geography Type and SRIDs       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; The Geography Type and Coordinate Ordering       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Coordinate Systems and Units of Measure       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; The Extent of Geography Objects       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Spatial Data Validity       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Data Validity Issues with Geometry Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Measuring Length and Area       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Comparing Length Measurements between GEOMETRY and GEOGRAPHY Instances       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Comparing Area Measurements between GEOMETRY and GEOGRAPHY Instances       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Indexing Spatial Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Spatial Index Basics       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SQL Server Spatial Indexes       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Using Spatial Indexes       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Geography Indexes       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Query Plans       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Integration with Spatial Methods       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Using Spatial Data to Solve Problems       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Loading Spatial Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Shape2SQL       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MapPoint 2009 Add-In for SQL Server       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Loading Spatial Data from Text Files       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Common Workflow Patterns       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Using the GEOMETRY MakeValid Method       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Forcing Polygon Ring Orientation       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Moving Geometry Data to Geography Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Using MakeValidGeographyFromGeometry       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Finding Site Locations within Geographic Regions       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Find High Schools with 2 KM of Interstate 5 in King County,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font face="Courier New"&gt;Washington State      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Find Schools Within 4 KM of the Intersection of Interstate 5 and      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Interstate 405 in King County, Washington State       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Nearest Neighbor Searches       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Find the Nearest GeoNames Data around a Point Location       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Find Zip Codes around a Point Location       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Spatial Joins       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Processing Spatial Data       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Processing the Highways Table in the Sample_USA Database       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; The WorkFlow       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Extending Spatial Support with CLR Routines&lt;/strong&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Types on the Client       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; User Defined Aggregate: Union and Dissolve       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Sinks and Builders: Linear Transformations       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;Conclusion&lt;/strong&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;My next post will cover the associated source code for the examples and the sample spatial data.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dc502de6-24a7-4fb0-91bd-867a2c93339e" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Inside+Microsoft+SQL+Server+2008" rel="tag"&gt;Inside Microsoft SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/T-SQL+Programming" rel="tag"&gt;T-SQL Programming&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL+Server+2008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/T-SQL" rel="tag"&gt;T-SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial+Data" rel="tag"&gt;Spatial Data&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Table+of+Contents" rel="tag"&gt;Table of Contents&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TOC" rel="tag"&gt;TOC&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9938497" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>My Overheating IBM ThinkPad T60p Laptop</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/11/13/my-overheating-ibm-t60p-laptop.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/11/13/my-overheating-ibm-t60p-laptop.aspx</id><published>2009-11-13T22:27:53Z</published><updated>2009-11-13T22:27:53Z</updated><content type="html">&lt;p&gt;My faithful old IBM T60p laptop has been with me for years.&amp;#160; Over time, and every so slowly, it has been running hotter and hotter (especially when running complex spatial queries on SQL Server 2008 or generating map-based reports using the new SQL Server 2008 R2 Report Builder… ;-).&amp;#160; A few weeks ago it got so hot that I had to take it off my lap … and then things went from bad to worse. Here’s the tale…&lt;/p&gt;  &lt;p&gt;I decided that it was time to upgrade to Windows 7.&amp;#160; I ordered a new Seagate 7200rpm 320GB hard drive for the laptop.&amp;#160; I took the old internal hard drive out and put it into a NexStar3 USB2.0/eSATA 2.5-inch enclosure …&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/MYOVERHEATINGIBMT60pLAPTOP_B63D/clip_image001_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/MYOVERHEATINGIBMT60pLAPTOP_B63D/clip_image001_thumb.jpg" width="244" height="126" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;… and proceeded to do a fresh install of Windows 7.&amp;#160; &lt;/p&gt;  &lt;p&gt;The Windows 7 install went flawlessly.&amp;#160; Even the most difficult (anticipated) parts of the install – new drivers for printers and other devices - went very smoothly.&amp;#160; In my case, Windows 7 found all of the drivers automatically over the Net including the driver for the eSATA Express Port card necessary to connect to my NexStar3-enclosed hard drive with all my data on it.&amp;#160; So far so good.&lt;/p&gt;  &lt;p&gt;Then bad things begin to happen – for no apparent reason, the laptop started to shut down all by itself.&amp;#160; After having this happen a few times (Windows 7, btw, recovered very nicely each time),&amp;#160; I concluded that the shut downs occurred when the machine got very, very hot – perhaps a heat related shutdown? I did a web search to see if others were having this problem. I appeared to be all alone.&amp;#160; I speculated that it might be one of the following reasons:&lt;/p&gt;  &lt;p&gt;1.&amp;#160; My use of an underpowered 65W power supply (its supposed to be a 90W supply but that brick is much larger and I had consequently been using the smaller power supply for the last couple of years).&lt;/p&gt;  &lt;p&gt;2. The new operating system, Windows 7.&amp;#160; I imagined that Windows 7 was using the CPU or GPU (or both) just a little bit harder than Vista and this was pushing the laptop “over the edge”.&lt;/p&gt;  &lt;p&gt;After swapping out the 65W power brick for the proper 90W unit, it was still overheating and shutting down.&amp;#160; I figured it had to be Windows 7.&amp;#160; Desperate, I sought advice from the hardware technician who supports the SQL Server engineering team.&amp;#160; He had a very simple suggestion:&lt;/p&gt;  &lt;p&gt;1. Shut the machine down&lt;/p&gt;  &lt;p&gt;2. Use compressed air to blow out accumulated dust from the CPU/GPU ventilation system in the upper left-hand corner of the laptop.&lt;/p&gt;  &lt;p&gt;I was skeptical but, having nothing to lose, gave it a try. I liberally blasted both cooling ports on the laptop (see illustration, below)&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/MYOVERHEATINGIBMT60pLAPTOP_B63D/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/MYOVERHEATINGIBMT60pLAPTOP_B63D/image_thumb.png" width="536" height="437" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Several of the air blasts dislodged a noticeable amount of dust.&amp;#160; At the time it didn’t seem like enough to make any significant difference…&lt;/p&gt;  &lt;p&gt;I powered up the laptop. Even after several hours of continuous use the machine was running cool and behaving perfectly.&amp;#160; It’s now several days later and the laptop is running like new.&amp;#160; Windows 7 is a delight.&amp;#160; I installed SQL Server 2008 R2 on it easily and moved all of my spatial databases from the external hard drive to the laptop.&amp;#160; I even got up the nerve to try the new Office 2010 beta distribution and again no problems.&lt;/p&gt;  &lt;p&gt;The technician did say that it still might warrant a physical inspection of the cooling ports and further dust/cruft removal but this simple trick worked miracles on this particular machine. &lt;/p&gt;  &lt;p&gt;Here is a &lt;a href="http://www.arcamax.com/zits/s-652556-295452"&gt;cartoon&lt;/a&gt;, which just about sums it up.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e5ee02e5-d124-42d6-906b-c853d9f426bd" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/laptop" rel="tag"&gt;laptop&lt;/a&gt;,&lt;a href="http://technorati.com/tags/overheating" rel="tag"&gt;overheating&lt;/a&gt;,&lt;a href="http://technorati.com/tags/IBM" rel="tag"&gt;IBM&lt;/a&gt;,&lt;a href="http://technorati.com/tags/T60p" rel="tag"&gt;T60p&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9922282" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>A Spatially-Enabled Dinner In Austin, Texas: Some Observations Outside the Office</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/10/07/a-spatially-enabled-dinner-in-austin-texas-some-observations-outside-the-office.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/10/07/a-spatially-enabled-dinner-in-austin-texas-some-observations-outside-the-office.aspx</id><published>2009-10-07T19:02:44Z</published><updated>2009-10-07T19:02:44Z</updated><content type="html">&lt;p&gt;Not having posted for a while, I thought I'd take a few minutes and provide some thoughts on spatial after successfully negotiating dinner here in Austin, Texas (October 6, 2009).&amp;#160; I'm in town for the Texas GIS Forum, one of my favorite conferences, and always seek out barbeque when I can.&amp;#160; A quick check on Bing Maps verified that my hotel was very close to &lt;a href="http://www.rudys.com/" target="_blank"&gt;Rudy's Bar-B-Q&lt;/a&gt;.&amp;#160; I remembered that Rudy's was on a one-way road, next to a freeway, and wanted to verify my route using Live Search on my Windows Mobile Phone.&amp;#160; The route that it provided seemed counter-intuitive: it wanted to take me across the freeway and have me reverse my route at an overpass (see below).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_1.png" width="304" height="438" /&gt;&lt;/a&gt;&amp;#160;&lt;strong&gt;Bing Maps Route&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I chose a more straight-forward route and finally coerced Live Search on my mobile to guide me that way (after repeated, &amp;quot;reroute from current location?&amp;quot; messages...).&amp;#160; An added bonus was that Rudy's had an entrance off of my newly found route and I got there in a very direct fashion.&lt;/p&gt;  &lt;p&gt;When I got back to the hotel, I decided to see how Google Maps handled the same route request.&amp;#160; Google did the right thing and provided an almost ideal route (see below), though it is curious that Research Blvd, which parallels Highway 183 on both sides, is not shown - curious.&amp;#160; It too missed the back entrance to the restaurant, but that's a minor detail.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb.png" width="304" height="438" /&gt;&lt;/a&gt;&amp;#160;&lt;strong&gt;Google Maps Route&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When I got to Rudy's, I fired up the GPS-Photo tool on my mobile phone and took a series of images.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_263_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="GPS_263" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_263_thumb.jpg" width="404" height="304" /&gt;&lt;/a&gt;&lt;strong&gt;Entrance to Rudy's on Research Blvd.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_264_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="GPS_264" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_264_thumb.jpg" width="404" height="304" /&gt;&lt;/a&gt;&amp;#160;&lt;strong&gt;View from parking lot&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_260_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="GPS_260" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_260_thumb.jpg" width="404" height="304" /&gt;&lt;/a&gt;&lt;strong&gt; Outdoor seating is available...&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For dinner, I had the lean brisket, white bread, beans, potato salad and an &lt;a href="http://www.ibcrootbeer.com/" target="_blank"&gt;IBC Cream Soda&lt;/a&gt; - all for $12.19.&amp;#160; The foot was great but the beans needed some spicing up.&amp;#160; I added a bit of their famous barbeque sauce (below) to made the beans quite tasty... It was 91 degrees outside and quite humid (from my West Coast environment viewpoint) at 6:00 PM in the evening.&amp;#160; Perfect barbeque weather.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_261_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="GPS_261" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/GPS_261_thumb.jpg" width="304" height="404" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;strong&gt;Geocoded Barbeque Sauce&lt;/strong&gt; (latitude 30.414167, longitude: -97.7467, WGS84)&lt;/p&gt;  &lt;p&gt;When I got back to the hotel, I loaded each of the GPS-enabled images from the mobile phone into my favorite photo application: SpatialAlbum.&amp;#160; I'll blog more about this application at a later point, but, in short, it allows you to load GPS-enabled digital images, using a drag-an-drop interface, into SQL Server 2008.&amp;#160; It uses a lot of SQL Server 2008 goodies: spatial, sparse columns, filestreams, the new datetime2 type and overlays all spatial data on top of Bing Maps. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_2.png" width="404" height="342" /&gt;&lt;/a&gt; &lt;strong&gt;SpatialAlbum application&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Here is the location of the photos I took using the Bing Maps feature of SpatialAlbum:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_3.png" width="404" height="337" /&gt;&lt;/a&gt; &lt;strong&gt;Rudy's location on Bing Maps&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The following are some Bing Maps displays in SpatialAlbum showing various view/featues:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_4.png" width="404" height="337" /&gt;&lt;/a&gt; &lt;strong&gt;Synoptic view in the Aerial mode&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_12.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_5.png" width="404" height="337" /&gt;&lt;/a&gt;&lt;strong&gt; Bird's eye view from the south&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_16.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_7.png" width="404" height="337" /&gt;&lt;/a&gt;&lt;strong&gt; Bird's eye view showing back entrance...&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_18.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_8.png" width="404" height="337" /&gt;&lt;/a&gt;&lt;strong&gt; Bird's eye view from the north showing parking lot&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_20.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/ASpatiallyEnabledDinnerInAustinTexasSome_100FC/image_thumb_9.png" width="404" height="337" /&gt;&lt;/a&gt;&lt;strong&gt; Bird's eye view of the main entrance off Research Blvd.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;And there you have it - more information than you ever wanted on an obscure topic. Maybe I should do a WikiPedia page on Rudy's...&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:136d6217-001a-4978-9dce-861ee87ec9c1" class="wlWriterSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server%202008%20R2" rel="tag"&gt;SQL Server 2008 R2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/spatial" rel="tag"&gt;spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sparse%20columns" rel="tag"&gt;sparse columns&lt;/a&gt;,&lt;a href="http://technorati.com/tags/datetime2" rel="tag"&gt;datetime2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/filestream" rel="tag"&gt;filestream&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Bing%20Maps" rel="tag"&gt;Bing Maps&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Google%20Maps" rel="tag"&gt;Google Maps&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Bird's%20eye" rel="tag"&gt;Bird's eye&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SpatialAlbum" rel="tag"&gt;SpatialAlbum&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Austin" rel="tag"&gt;Austin&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Texas" rel="tag"&gt;Texas&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Rudy's" rel="tag"&gt;Rudy's&lt;/a&gt;,&lt;a href="http://technorati.com/tags/barbeque" rel="tag"&gt;barbeque&lt;/a&gt;,&lt;a href="http://technorati.com/tags/IBC" rel="tag"&gt;IBC&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Texas%20GIS%20Forum" rel="tag"&gt;Texas GIS Forum&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9904419" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Working with Invalid Data and the SQL Server 2008 Geography Data Type, Part 2</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/06/05/working-with-invalid-data-and-the-sql-server-2008-geography-data-type-part-2.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/06/05/working-with-invalid-data-and-the-sql-server-2008-geography-data-type-part-2.aspx</id><published>2009-06-06T08:09:33Z</published><updated>2009-06-06T08:09:33Z</updated><content type="html">&lt;p&gt;In a long past post, &lt;a href="http://blogs.msdn.com/edkatibah/archive/2008/08/19/working-with-invalid-data-and-the-sql-server-2008-geography-data-type-part-1b.aspx"&gt;Working with Invalid Data and the SQL Server 2008 Geography Data Type, Part 1b&lt;/a&gt; (August 2008), I discussed techniques for dealing with invalid data and the geography data type. In my last post, I listed the new geography validation functions in the &lt;a href="http://sqlspatialtools.codeplex.com/" target="_blank"&gt;SQL Server Spatial Tools project&lt;/a&gt; on CodePlex.&amp;#160; In this post, I'm going to use three of these new functions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font face="Courier New" size="2"&gt;IsValidGeographyFromGeometry&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font face="Courier New" size="2"&gt;MakeValidGeographyFromGeometry&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font face="Courier New" size="2"&gt;MakeValidGeographyFromText&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For this exercise, I'm going to use the &lt;a href="http://www.zillow.com/howto/api/neighborhood-boundaries.htm" target="_blank"&gt;Zillow Neighborhood Boundaries&lt;/a&gt; &lt;a href="http://www.zillow.com/howto/api/neighborhood-boundaries.htm" target="_blank"&gt;&lt;img src="http://www.zillow.com/vstatic/262bbefe8c95d3e90ac760b5b3c3a484/static/logos/Zillow_Logo_HoodsProvided_RTAligned.gif" /&gt;&lt;/a&gt;.&amp;#160; Since the neighborhood data (polygons) are delivered as shapefiles, I used the well respected &lt;a href="http://www.sharpgis.net/page/SQL-Server-2008-Spatial-Tools.aspx" target="_blank"&gt;Shape2SQL data loader&lt;/a&gt; from &lt;a href="http://www.sharpgis.net/" target="_blank"&gt;SharpGIS&lt;/a&gt;. Note that there are 42 individual state-based shapefiles which will need to be individually downloaded and then loaded into SQL Server. Since the goal of this exercise is to end up with geography features, the data must be in geographic coordinates to start with. The projection file (.prj) associated with each shapefile confirmed this, containing the following information:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;GEOGCS[&amp;quot;GCS_North_American_1983&amp;quot;,DATUM[&amp;quot;D_North_American_1983&amp;quot;,SPHEROID[&amp;quot;GRS_1980&amp;quot;,6378137.0,298.257222101]],PRIMEM[&amp;quot;Greenwich&amp;quot;,0.0],UNIT[&amp;quot;Degree&amp;quot;,0.0174532925199433]]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This is EPSG:4269, so that's the SRID I used in Shape2SQL. &lt;/p&gt;  &lt;p&gt;My goal is to load this data into a column of type geography so it would make sense to load the data directly into a geography column.&amp;#160; I'll save you the suspense and tell you right now that that some of this data will not load directly into a geography column - big surprise, right?&amp;#160; Consequently, I&amp;#160; loaded each shapefile's spatial data directly into a table, ZillowNeighborhoods, with a geometry column named GEOM.&amp;#160; After the data loading was completed, I added a column of type geography named GEOG:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;ALTER TABLE ZillowNeighborhoods     &lt;br /&gt;&amp;#160; ADD GEOG geography NOT NULL&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Being bold, I next attempted to use the new &lt;font face="Courier New" size="2"&gt;MakeValidGeographyFromGeometry&lt;/font&gt; function to update the new geography column:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;UPDATE ZillowNeighborhoods&amp;#160; &lt;br /&gt;&amp;#160; SET GEOG = dbo.MakeValidGeographyFromGeometry(GEOM)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Well, suffice-it-to-say, it wasn't quite that easy, even with our new fangled function, which returned the following error message:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;Msg 6522, Level 16, State 1, Line 1      &lt;br /&gt;A .NET Framework error occurred during execution of user-defined routine or aggregate &amp;quot;MakeValidGeographyFromGeometry&amp;quot;:       &lt;br /&gt;System.ArgumentException: 24200: The specified input does not represent a valid geography instance.&lt;/font&gt; &lt;/p&gt;  &lt;p&gt; So, what to do next? Why not use the IsValidGeographyFromGeometry function so identify the candidate group of which geometries contained invalid data from a geography-perspective:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT ID FROM ZillowNeighborhoods WHERE dbo.IsValidGeographyFromGeometry(GEOM) = 0     &lt;br /&gt;--Results:      &lt;br /&gt;--3499      &lt;br /&gt;--4319      &lt;br /&gt;--4328      &lt;br /&gt;--4428      &lt;br /&gt;--4458      &lt;br /&gt;--5182      &lt;br /&gt;--5201      &lt;br /&gt;--5214      &lt;br /&gt;--5224&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now I needed to figure out which of these geometries could not be converted, so I used the following query, once for each ID:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT dbo.MakeValidGeographyFromGeometry(GEOM) FROM ZillowNeighborhoods WHERE ID = 3499&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The queries which failed allowed me to isolate the problem geometries to the following rows (identified by the ID field):&amp;#160; &lt;/p&gt;  &lt;p&gt;3499, 4328, 5224&lt;/p&gt;  &lt;p&gt;Before I go any further, let's update the geography column, sans the problematic polygons:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;UPDATE ZillowNeighborhoods     &lt;br /&gt;&amp;#160; SET GEOG = dbo.MakeValidGeographyFromGeometry(GEOM)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE ID NOT IN (3499, 4328, 5224)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now, let's investigate the problem geometries to see if we can determine what the issues are that prevent conversion. Here is the first troublesome geometry (ID = 3499):&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT GEOM FROM ZillowNeighborhoods WHERE ID = 3499&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is the returned geometry in the Spatial results tab in Management Studio:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/clip_image001_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="226" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/clip_image001_thumb.png" width="573" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;A careful visual analysis didn't find any obvious defects in the geometry.&lt;/p&gt;  &lt;p&gt;Then, I decided to fiddle with the original geometry using the Reduce method with very small tolerances. Interestingly enough, I was able to get the geometry to convert to a geography using the following query:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT dbo.MakeValidGeographyFromGeometry(GEOM.Reduce(.0000001))      &lt;br /&gt;&amp;#160; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;FROM ZillowNeighborhoods WHERE ID = 3499&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;So what is happening here?&amp;#160; First of all, the tolerance used in the Reduce method is very small. So how many vertex points were removed from the original geometry by Reduce?&amp;#160; It turns out that 6 vertices were removed. A quick discussion with the SQL Server spatial developers revealed that during current validation processing some very close vertices can shift slightly and cause edges to cross/overlap (remember that geographic edges are not straight lines...).&amp;#160; In the next release of SQL Server (SQL11), we have changed the underlying methodology and eliminated this issue.&amp;#160; For now, we will have to workaround this issue using Reduce with very small tolerances.&amp;#160; &lt;/p&gt;  &lt;p&gt;By chance, I happened to look at the comments on my August 2008 post, referenced above, and found that I was not the first one to discover this technique:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;# Craig Tadlock said on February 16, 2009 9:36 PM:      &lt;br /&gt;This is an excellent post. It works for 99.9% of the geometries Ive had to deal with. For the other .1%, try adding this.. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Reduce the geometry value by a very small amount 1st. I'm not actually sure what this does internally, but it's solved most my issues. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Example... &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;select geography::STGeomFromWKB(geom.MakeValid().Reduce(.00000001).STUnion(geom.STStartPoint()).MakeValid().STAsBinary(), 4326) from tl_2008_us_csa&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;So, my hat's off to you, Craig, a true invalid geography pioneer!&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; I've subsequently done a little more investigation and found that Alastair (author of the first published SQL Server Spatial &lt;/em&gt;&lt;em&gt;book&lt;/em&gt;&lt;em&gt;, &lt;a href="http://www.apress.com/book/view/1430218290" target="_blank"&gt;Beginning Spatial with SQL Server 2008&lt;/a&gt;)&amp;#160; had already figured this trick out in his excellent post, &lt;/em&gt;&lt;a href="http://www.beginningspatial.com/fixing_invalid_geography_data" target="_blank"&gt;&lt;em&gt;Fixing Invalid Geography Data&lt;/em&gt;&lt;/a&gt;&amp;#160;&lt;em&gt;(Oct. 18, 2008). Nothing like &amp;quot;discovering&amp;quot; what everybody else already knew ;-)&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To complete the investigation, let's see if we can isolate the vertexes which were removed by Reduce. To do this I buffered the difference polygons between the original and generalized polygons using the following query:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;--Find problem areas and mark with a buffer polygon     &lt;br /&gt;DECLARE @g0 GEOMETRY      &lt;br /&gt;DECLARE @g1 GEOMETRY&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT @g1 = GEOM.Reduce(.00000001) FROM ZillowNeighborhoods WHERE ID = 3499     &lt;br /&gt;&lt;font face="Courier New" size="2"&gt;SELECT &lt;/font&gt;@g0 = GEOM FROM ZillowNeighborhoods WHERE ID = 3499 &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;     &lt;br /&gt;&amp;#160; &lt;br /&gt;&lt;font face="Courier New" size="2"&gt;SELECT &lt;/font&gt;@g0.STDifference(@g1).STBuffer(.001)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Using Safe Software's Feature Manipulation Engine's (FME) Universal Viewer, I've created the following visualization where I&amp;#8217;ve overlaid the original and generalized geometry over each other with the modified areas indicated by the buffer regions generated with the above query. I then marked the obvious vertexes which were removed by the Reduce in the Windows Paint program. The remaining vertexes where so close to other vertexes that it was not possible to actually identify them, though it is clear where they are.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="229" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_thumb.png" width="592" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Needless-to-say, the generalized polygon with this tiny tolerance did not materially change the polygon's basic geometric quality. So I would posit that this technique is a valid method.&amp;#160; To complete this sequence, I updated the row where ID=3499 with the following query: &lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;UPDATE ZillowNeighborhoods     &lt;br /&gt;&amp;#160; SET GEOG = dbo.MakeValidGeographyFromGeometry(GEOM.Reduce(.00000001))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE ID = 3499&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;So what about the other two polygons which would not convert (ID's: 4328, 5224)?&amp;#160; Well it turns out the &amp;quot;Reduce&amp;quot; technique works for these too.&amp;#160; But there is a twist ... it wouldn't be any fun if I was done, right?&lt;/p&gt;  &lt;p&gt;It turns out that when run through the Reduce-based technique, each of these geometries produces GeometryCollections:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; The SQL Server Spatial Team has entertained many inquiries on why Reduce, under certain circumstances, would take higher dimension objects (such as polygons) and create lower dimension objects (such as lines and points) from them (most other spatial databases maintain the dimensionality of the spatial object when generalizing).&amp;#160; The following examples are a good illustration of how to capitalize on the behavior of Reduce when it encounters extremely thin polygons.&lt;/em&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is the Well-Known Text (WKT) for ID = 5224 from the following query:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT GEOM.Reduce(.0000001).STAsText() FROM ZillowNeighborhoods WHERE ID = 5224&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;GEOMETRYCOLLECTION (LINESTRING (-86.7028556317091 36.198983579874039, -86.702864557504654 36.198975399136543), LINESTRING (-86.72271192073822 36.195485174655914, -86.7227138876915 36.195484921336174), LINESTRING (-86.725671902298927 36.1651765704155, -86.7256792485714 36.165166437625885), POLYGON ((-86.724177449941635 36.164932250976562, -86.72216959297657 36.165002837777138, -86.720163896679878 36.165325194597244, ... , -86.725447744131088 36.164976820349693, -86.724177449941635 36.164932250976562)))&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;So what's with the LINESTRING's?&amp;#160; Let's take a look. &lt;/p&gt;  &lt;p&gt;First, let's create geometry instances from each of the LINESTRINGs.&amp;#160; Since the LINESTRINGs are very small, let's buffer them to help make the area where there occur along the polygon visible:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @g1 VARCHAR(MAX) = 'LINESTRING (-86.7028556317091 36.198983579874046, -86.702864557504654 36.19897539913655)'     &lt;br /&gt;DECLARE @g2 VARCHAR(MAX) = 'LINESTRING (-86.72271192073822 36.195485174655914, -86.7227138876915 36.195484921336167)'      &lt;br /&gt;DECLARE @g3 VARCHAR(MAX) = 'LINESTRING (-86.725671902298942 36.1651765704155, -86.7256792485714 36.165166437625885)' &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT GEOMETRY::STGeomFromText(@g1,4269).STBuffer(.001)     &lt;br /&gt;UNION ALL      &lt;br /&gt;SELECT GEOMETRY::STGeomFromText(@g2,4269).STBuffer(.001)      &lt;br /&gt;UNION ALL      &lt;br /&gt;SELECT GEOMETRY::STGeomFromText(@g3,4269).STBuffer(.001)      &lt;br /&gt;UNION ALL      &lt;br /&gt;SELECT GEOM FROM ZillowNeighborhoods WHERE ID = 5224&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is the view from Management Studio:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="459" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_thumb_1.png" width="507" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Let's &amp;quot;zoom&amp;quot; in on a single problem area:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-----------------------------------------------------------------------     &lt;br /&gt;-- Isolate one of the problem areas which is identified by the linestring ...      &lt;br /&gt;-----------------------------------------------------------------------      &lt;br /&gt;-- Define linestring      &lt;br /&gt;DECLARE @g1 VARCHAR(MAX) = 'LINESTRING (-86.7028556317091 36.198983579874046, -86.702864557504654 36.19897539913655)'      &lt;br /&gt;-- Clip the original geometry instance by intersecting a buffer around the linestring with the original geometry instance      &lt;br /&gt;SELECT GEOMETRY::STGeomFromText(@g1,4269).STBuffer(.0001).STIntersection(GEOM)       &lt;br /&gt;&amp;#160; FROM ZillowNeighborhoods WHERE ID = 5224      &lt;br /&gt;UNION ALL      &lt;br /&gt;SELECT GEOMETRY::STGeomFromText(@g1,4269).STBuffer(.00001)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is how this looks in Management Studio:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="455" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_thumb_3.png" width="528" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So the LINESTRING is a &amp;quot;spike&amp;quot;. The &amp;quot;line&amp;quot; in the brown buffer region is actually an extremely thin extension of the base polygon. It turns out that the rest of the LINESTRINGs are also spikes.&amp;#160; The last geometry (ID = 4328) was likewise festooned with spikes.&amp;#160; A quick recap on why spikes cause validation issues, from above: &lt;em&gt;&amp;quot;...during current validation processing some very close vertices can shift slightly to cause edges to cross/overlap&amp;quot;. &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;To create the final geometry objects, ready for conversion to geography, simply extract the POLYGON WKT from the GEOMETRYCOLLECTIONS returned by the Reduce-based processing and create geometry instances which can then be used to update the original geometry after conversion by MakeValidGeographyFromText (note the use this new function):&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @geom VARCHAR(MAX) = POLYGON ((-86.724177449941635 36.164932250976562, -86.72216959297657 36.165002837777138, ..., -86.725447744131088 36.164976820349693, -86.724177449941635 36.164932250976562))'&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;UPDATE ZillowNeighborhoods     &lt;br /&gt;&amp;#160; SET GEOG = dbo.MakeValidGeographyFromText(@geom,4269)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE ID = 5224&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Let's fix the last neighborhood polygon, ID=4328.&amp;#160; A quick check shows that the core neighborhood polygon is actually a MULTIPOLYGON:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT * FROM ZillowNeighborhoods WHERe ID = 4328&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="301" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WorkingwithInvalidDataandtheSQLServer200_105C7/image_thumb_4.png" width="518" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;A quick check of the structure of the MULTIPOLYGON with the following query...&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT dbo.MakeValidGeographyFromGeometry(GEOM.Reduce(.00000001)).STAsText()      &lt;br /&gt;&amp;#160; FROM ZillowNeighborhoods       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE ID = 4328&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;...reveals that there are 4 polygons (expected) and 1 line (a &amp;quot;spike&amp;quot;) in the GEOMETRYCOLLECTION.&amp;#160; I removed the LINESTRING from the WKT and, using the following query, updated the row:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @geom VARCHAR(MAX) = 'GEOMETRYCOLLECTION (POLYGON ((-73.8411675542593 40.795716315507896, ..., -73.8411675542593 40.795716315507896)), POLYGON ((-73.853304713964462 40.7884576357901, ..., -73.853304713964462 40.7884576357901)), POLYGON ((-73.85657873749733 40.78686719387769, ..., -73.85657873749733 40.78686719387769)), POLYGON ((-73.85907343775034 40.785239797085531, ..., -73.85907343775034 40.785239797085531)))'     &lt;br /&gt;DECLARE @geog GEOGRAPHY      &lt;br /&gt;SELECT @geog = dbo.MakeValidGeographyFromText(@geom,4269)      &lt;br /&gt;UPDATE ZillowNeighborhoods      &lt;br /&gt;&amp;#160; SET GEOG = @geog      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE ID = 4328&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This completes the exercise, updating the ZillowNeighborhoods table with a column of type geography.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f8b668e5-da69-42ea-9556-c618325cd787" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/MakeValidGeographyFromGeometry" rel="tag"&gt;MakeValidGeographyFromGeometry&lt;/a&gt;,&lt;a href="http://technorati.com/tags/MakeValidGeographyFromText" rel="tag"&gt;MakeValidGeographyFromText&lt;/a&gt;,&lt;a href="http://technorati.com/tags/IsValidGeographyFromGeometry" rel="tag"&gt;IsValidGeographyFromGeometry&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Shape2SQL" rel="tag"&gt;Shape2SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SharpGIS" rel="tag"&gt;SharpGIS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CodePlex" rel="tag"&gt;CodePlex&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Geography" rel="tag"&gt;Geography&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Validation" rel="tag"&gt;Validation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Zillow" rel="tag"&gt;Zillow&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Neighborhoods" rel="tag"&gt;Neighborhoods&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Safe%20Software" rel="tag"&gt;Safe Software&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Feature%20Manipulation%20Engine" rel="tag"&gt;Feature Manipulation Engine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FME" rel="tag"&gt;FME&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Universal%20Viewer" rel="tag"&gt;Universal Viewer&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9702548" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>Update to the SQL Server Spatial Tools project on CodePlex</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/06/05/update-to-the-sql-server-spatial-tools-project-on-codeplex.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/06/05/update-to-the-sql-server-spatial-tools-project-on-codeplex.aspx</id><published>2009-06-05T20:15:55Z</published><updated>2009-06-05T20:15:55Z</updated><content type="html">&lt;p&gt;As Isaac noted in his most recent &lt;a href="http://blogs.msdn.com/isaac/archive/2009/06/02/new-stuff-in-sql-spatial-tools.aspx" target="_blank"&gt;post&lt;/a&gt;, the &lt;a href="http://sqlspatialtools.codeplex.com/" target="_blank"&gt;SQL Server Spatial Tools project&lt;/a&gt; on CodePlex has been updated with several new geography functions. This post provides additional detail on the new features:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;u&gt;IsValidGeographyFromGeometry&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;&lt;u&gt;IsValidGeographyFromText&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;&lt;u&gt;MakeValidGeographyFromGeometry&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;&lt;u&gt;MakeValidGeographyFromText&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;&lt;u&gt;ConvexHullGeography&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;&lt;u&gt;ConvexHullFromText&lt;/u&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here are descriptions for each:&lt;/p&gt;  &lt;p&gt;&lt;u&gt;bool &lt;b&gt;IsValidGeographyFromGeometry&lt;/b&gt;(SqlGeometry geometry)&lt;/u&gt;    &lt;br /&gt;Check if an input geometry can represent a valid geography without throwing an exception. This function requires that the geometry be in longitude/latitude coordinates and that those coordinates are in correct order in the geometry instance (i.e. latitude/longitude not longitude/latitude). This function will return false (0) if the input geometry is not in the correct latitude/longitude format, including a valid geography SRID.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;bool &lt;b&gt;IsValidGeographyFromText&lt;/b&gt;(string inputWKT, int srid)&lt;/u&gt;    &lt;br /&gt;Check if an input WKT can represent a valid geography. This function requires that the WTK coordinate values are longitude/latitude values, in that order and that a valid geography SRID value is supplied. This function will not throw an exception even in edge conditions (i.e. longitude/latitude coordinates are reversed to latitude/longitude).&lt;/p&gt;  &lt;p&gt;&lt;u&gt;SqlGeography &lt;b&gt;MakeValidGeographyFromGeometry&lt;/b&gt;(SqlGeometry geometry)&lt;/u&gt;    &lt;br /&gt;Convert an input geometry instance to a valid geography instance. This function requires that the WKT coordinate values are longitude/latitude values, in that order and that a valid geography SRID value is supplied.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;SqlGeography &lt;b&gt;MakeValidGeographyFromText&lt;/b&gt;(string inputWKT, int srid)&lt;/u&gt;    &lt;br /&gt;Convert an input WKT to a valid geography instance. This function requires that the WKT coordinate values are longitude/latitude values, in that order and that a valid geography SRID value is supplied.&lt;/p&gt;  &lt;p&gt;&lt;u&gt;SqlGeography &lt;b&gt;ConvexHullGeography&lt;/b&gt;(SqlGeography geography)&lt;/u&gt;    &lt;br /&gt;Computes ConvexHull of input geography and returns a polygon (unless all input points are collinear).&lt;/p&gt;  &lt;p&gt;&lt;u&gt;SqlGeography &lt;b&gt;ConvexHullGeographyFromText&lt;/b&gt;(string inputWKT, int srid)&lt;/u&gt;    &lt;br /&gt;Computes ConvexHull of input WKT and returns a polygon (unless all input points are collinear). This function does not require its input to be a valid geography. This function does require that the WKT coordinate values are longitude/latitude values, in that order and that a valid geography SRID value is supplied.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4008fd73-d15e-4cff-8ad4-9448d98a1ca5" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ConvexHull" rel="tag"&gt;ConvexHull&lt;/a&gt;,&lt;a href="http://technorati.com/tags/MakeValid" rel="tag"&gt;MakeValid&lt;/a&gt;,&lt;a href="http://technorati.com/tags/IsValid" rel="tag"&gt;IsValid&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Geography" rel="tag"&gt;Geography&lt;/a&gt;,&lt;a href="http://technorati.com/tags/functions" rel="tag"&gt;functions&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9701665" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 5</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/05/18/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-5.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/05/18/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-5.aspx</id><published>2009-05-19T01:27:55Z</published><updated>2009-05-19T01:27:55Z</updated><content type="html">&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;The Report Builder, a component of Reporting Services, described in this post will be available as a separate download when the upcoming CTP2 release of SQL Server 2008 Release 2 (R2) is made available to the public, currently scheduled for August 2009.&lt;/u&gt;&lt;/strong&gt;&lt;/em&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This was to be the last post in this series but it's too interesting to stop here.&amp;#160; As of this writing, I'm planning one additional post in this series which will expand on the new mapping capabilities of SQL Server Reporting Services.&amp;#160; Please note that these new capabilities will be introduced in CTP2 of the upcoming SQL Server 2008, R2 release. Today's post will introduce the new SQL Server Report Builder and its new mapping capabilities. Here is the workflow presented so far:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Locate data source and download (Part 1) &lt;/li&gt;    &lt;li&gt;Load the data into SQL Server (Part 1) &lt;/li&gt;    &lt;li&gt;Remove unwanted features, simplify Alaska and Hawaii spatial features (Part 2) &lt;/li&gt;    &lt;li&gt;&amp;quot;Reposition&amp;quot; Alaska and Hawaii cartographically (Part 3) &lt;/li&gt;    &lt;li&gt;Locate and load State-based population data (Part 4) &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;&lt;u&gt;Use the data in the new SQL Server Report Builder&lt;/u&gt;&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;More SQL Server Report Builder &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So that you don't have to immediately scroll to the end of this post to see the final result, here is a reduced scale version of the final map report, noting, of course, the repositioned Alaska and Hawaii features ;-):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_63.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="366" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_30.png" width="433" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;For those of you interested in the Report Builder workflow to create this map, please keep reading.&lt;/p&gt;  &lt;p&gt;When the new Report Builder is first opened, a design canvas is presented, allowing you to select on of three report wizards: Table, Chart or Map.&amp;#160; Since we have just finished adjusting a set of spatial data, the Map wizard looks like the ticket:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="459" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_3.png" width="757" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;When Map is selected, you will be presented with a wizard which will take your through the creation of your first map report.&lt;/p&gt;  &lt;p&gt;The first wizard menu presents you with a selection of spatial data sources. For this post we are going to use SQL Server spatial data:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_5.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_1.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The next step is to create a new data source connection:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_9.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_3.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Selecting &amp;quot;New...&amp;quot; brings up the next screen:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_11.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_4.png" width="585" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We have the option to create a new data source name but for this exercise, we won't change the default name.&amp;#160; Selecting the &amp;quot;Build...&amp;quot; button displays the Connection Properties menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_13.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="531" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_5.png" width="390" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here we will define our database server instance, authenticate the connection and connect to a database:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_15.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="530" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_6.png" width="390" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Hitting &amp;quot;OK&amp;quot; brings up the next panel.&amp;#160; Since this looks good, we'll hit &amp;quot;OK&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_17.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_7.png" width="585" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This looks good, so we'll hit &amp;quot;Next &amp;gt;&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_19.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_8.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The query designer is now presented.&amp;#160; We'll select &amp;quot;Edit As Text&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_21.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_9.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is the basic query we intend to use:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT STATEFP, GEOM FROM US_STATES_INSET&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This initial query selected columns &lt;font face="courier new"&gt;STATEFP&lt;/font&gt; and &lt;font face="Courier New"&gt;GEOM&lt;/font&gt; with the goal of using the State FIPS Codes in the &lt;font face="courier new"&gt;STATEFP&lt;/font&gt; column as the join column with the &lt;font face="Courier New"&gt;US_STATES_POPULATION&lt;/font&gt; table.&amp;#160; The join column in the &lt;font face="Courier New"&gt;US_STATES_POPULATION&lt;/font&gt; table is the &lt;font face="Courier New"&gt;STATES&lt;/font&gt; column, also containing FIPS Codes for the States. A quick review of the two join columns revealed a basic incompatibility despite the fact that they were both defined as character columns:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="279" border="1"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="93"&gt;&lt;strong&gt;STATEFP&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="79"&gt;&lt;strong&gt;STATES&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="105"&gt;&lt;strong&gt;NAME&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="94"&gt;01&lt;/td&gt;        &lt;td valign="top" width="81"&gt;1&lt;/td&gt;        &lt;td valign="top" width="105"&gt;Alabama&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;02&lt;/td&gt;        &lt;td valign="top" width="82"&gt;2&lt;/td&gt;        &lt;td valign="top" width="105"&gt;Alaska&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;04&lt;/td&gt;        &lt;td valign="top" width="83"&gt;4&lt;/td&gt;        &lt;td valign="top" width="105"&gt;Arizona&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;05&lt;/td&gt;        &lt;td valign="top" width="84"&gt;5&lt;/td&gt;        &lt;td valign="top" width="105"&gt;Arkansas&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;06&lt;/td&gt;        &lt;td valign="top" width="84"&gt;6&lt;/td&gt;        &lt;td valign="top" width="105"&gt;California&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;08&lt;/td&gt;        &lt;td valign="top" width="84"&gt;8&lt;/td&gt;        &lt;td valign="top" width="105"&gt;Colorado&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="95"&gt;09&lt;/td&gt;        &lt;td valign="top" width="84"&gt;9&lt;/td&gt;        &lt;td valign="top" width="105"&gt;Connecticut&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;to make the two join columns compatible, we can cast the character columns to integer.&amp;#160; Here is the rewrite for the current query:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT CAST(STATEFP AS INT) AS STATEFP, GEOM FROM US_STATES_INSET&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;We will use this query in the query designer.&amp;#160; Hitting &amp;quot;!&amp;quot; button will execute this query, with the results displayed in the bottom window, below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_25.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="429" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_11.png" width="509" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Selecting the &amp;quot;Next &amp;gt;&amp;quot; button brings up the following menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_27.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_12.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This all looks good, so we will select &amp;quot;Next &amp;gt;&amp;quot; here also and bring up the visualization menu, where we will choose &amp;quot;Color Analytical Map&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_29.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_13.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Choosing &amp;quot;Next &amp;gt;&amp;quot; brings up the &amp;quot;Choose the analytical dataset&amp;quot; menu.&amp;#160; Our analytical data will come from the &lt;font face="Courier New"&gt;US_STATES_POPULATION&lt;/font&gt; table, se we nee to select the &amp;quot;Create a dataset&amp;quot; radio button:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_31.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_14.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Choosing &amp;quot;Next &amp;gt;&amp;quot; brings up the menu panel which allows us to choose a connection to the new dataset.&amp;#160; Since the &lt;font face="Courier New"&gt;US_STATES_POPULATION&lt;/font&gt; table is in the same database as the spatial table (&lt;font face="Courier New"&gt;US_STATES_INSET&lt;/font&gt;), we can use the existing connection, DataSource1:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_33.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_15.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Choosing &amp;quot;Next &amp;gt;&amp;quot; bring us to the query designer screen for the analytical data:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_35.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_16.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As with the query designer for the spatial data, we well choose &amp;quot;Edit As Text&amp;quot; and use the following query:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT CAST(STATE AS INT) AS STATE, POPESTIMATE2008 FROM US_STATES_POPULATION&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Our intent is to join the two tables and display the 2008 population estimates (&lt;font face="Courier New"&gt;POPESTIMATE2008&lt;/font&gt; column) for each state on the resulting map.&amp;#160; As will recall, we are casting the State FIPS Code to integer to guarantee join compatibility on the join columns.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_37.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_17.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After selecting &amp;quot;Next &amp;gt;&amp;quot;, we are offered the opportunity to specify the join columns:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_39.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_18.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Checking the &amp;quot;Key&amp;quot; box allows us to specify the analytical fields in the &lt;font face="Courier New"&gt;US_STATES_POPULATION&lt;/font&gt; table query we just specified - in this case Map Binding Field: &lt;font face="Courier New"&gt;STATEFP&lt;/font&gt;, Analytical Field: &lt;font face="Courier New"&gt;STATE&lt;/font&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_43.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="430" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_20.png" width="510" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select &amp;quot;Next &amp;gt;&amp;quot; to bring up the color theme and data visualization menu.&amp;#160; Here we select the data field (analytical field) which will be symbolized by different polygon fill colors based on, in this case, population:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_45.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="429" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_21.png" width="509" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Selecting &amp;quot;Finish &amp;gt;&amp;gt;&amp;quot; brings up the design canvas.&amp;#160; In the version of the Report Builder that is being used for this post, there is a bug which prevents the map display from rendering the underlying spatial data correctly.&amp;#160; In order to remedy this, we need to set the coordinate system for the map display (It currently defaults to the geography data type. Since the &lt;font face="Courier New"&gt;GEOM&lt;/font&gt; column in the &lt;font face="Courier New"&gt;US_STATES_INSET&lt;/font&gt; table is of type geometry, the design-time display is not correct):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_49.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="492" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_23.png" width="587" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;To set the correct coordinate system, left-mouse-click on the design canvas to select and then right-click with the mouse to bring up the contextual menu.&amp;#160; What we are looking for are the &amp;quot;Viewport Properties...&amp;quot;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_51.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="498" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_24.png" width="588" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the &amp;quot;Viewport Properties...&amp;quot; allows us to set the Map coordinate system to Planar (X,Y).&amp;#160; In future versions of the Report Builder, the coordinate system will be automatically detected.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_53.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_25.png" width="585" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Selecting &amp;quot;OK&amp;quot; completes the task and the design canvas correctly illustrates the United States inset map.&amp;#160; Note that the map is not yet rendered and the design canvas map display is simply a placeholder. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_55.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="496" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_26.png" width="588" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the design canvas, we can adjust the map a bit, moving the color scale bar to the right and adding a title.&amp;#160; When done, we can render the final map by choosing&amp;#160; &amp;quot;Run&amp;quot; from the main menu ribbon of the Report Builder:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_57.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="399" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image_thumb_27.png" width="397" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When rendering is completed, the following report is produced:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image142.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="437" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_13548/image142_thumb.png" width="610" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the next post, Part 6, we will explore some additional capabilities of the Report Builder to finish off the series.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ffb23996-3e60-4fa1-a775-ff3292ce6f1f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server%202008" rel="tag"&gt;SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Server%202008%20R2" rel="tag"&gt;SQL Server 2008 R2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CTP-2" rel="tag"&gt;CTP-2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CTP2" rel="tag"&gt;CTP2&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Reporting%20Services" rel="tag"&gt;Reporting Services&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Report%20Builder" rel="tag"&gt;Report Builder&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SSRS" rel="tag"&gt;SSRS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Map" rel="tag"&gt;Map&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Server%20Reporting%20Services" rel="tag"&gt;SQL Server Reporting Services&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9626257" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 4</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/05/17/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-4.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/05/17/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-4.aspx</id><published>2009-05-18T07:53:36Z</published><updated>2009-05-18T07:53:36Z</updated><content type="html">&lt;p&gt;In the previous posts I indicated that this would be the last post in this series but it turned out that I was a bit optimistic. In order to make the final Report Builder post relevant, some interesting data for analysis was needed.&amp;#160; In this post we describe where to find and how to load State-based population data - our &amp;quot;interesting data&amp;quot;.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Locate data source and download (Part 1) &lt;/li&gt;    &lt;li&gt;Load the data into SQL Server (Part 1) &lt;/li&gt;    &lt;li&gt;Remove unwanted features, simplify Alaska and Hawaii spatial features (Part 2) &lt;/li&gt;    &lt;li&gt;&amp;quot;Reposition&amp;quot; Alaska and Hawaii cartographically (Part 3) &lt;/li&gt;    &lt;li&gt;&lt;u&gt;&lt;strong&gt;Locate and load State-based population data&lt;/strong&gt;&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;Use the data in the new SQL Server Report Builder &lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;LOCATING STATE POPULATION DATA&lt;/h3&gt;  &lt;p&gt;Our search for population data by State was satisfied at the &lt;a href="http://www.census.gov/popest/states/" target="_blank"&gt;US Census Bureau Population Estimates&lt;/a&gt; site.&amp;#160; There are a number of data files which are available, but I chose &lt;a href="http://www.census.gov/popest/national/files/NST-EST2008-alldata.csv" target="_blank"&gt;Population, Population change and estimated components of population change: April 1, 2000 to July 1, 2008 (NST-EST2008-alldata)&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;This data is delivered as commas-separated-value (CSV) ASCII.&amp;#160; This data was opened in Excel and saved as Text (Tab delimited).&lt;/p&gt;  &lt;h3&gt;LOADING STATE POPULATION DATA&lt;/h3&gt;  &lt;p&gt;Now we are going to use FME to do something for which it is not well known - loading data with no spatial component. &lt;/p&gt;  &lt;h4&gt;ADDING THE STATE POPULATION DATA AS THE SOURCE DATASET&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p&gt;In FME-speak, all ASCII data is format &amp;quot;Comma Separated Value (CSV)&amp;quot;.&amp;#160; Consequently, we choose CSV as our format - never mind that our data is tab separated values.&amp;#160; Next we locate the data using the &amp;quot;...&amp;quot; menu button.&amp;#160; After both the Format: and the Dataset: text fields are populated, choose the &amp;quot;Settings...&amp;quot; button.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_2.png" width="412" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;The &amp;quot;Settings...&amp;quot; button brings up a new menu panel which allows us to correctly define our field separator as &amp;quot;tab&amp;quot;.&amp;#160; Since our ASCII file contains field names, we want to make sure that this record is not interpreted as data.&amp;#160; In fact, we will use the field names as the columns names in the final database table. The CSV File Preview provides visual verification that we are correctly interpreting the file structure.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="716" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_3.png" width="526" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt; The source data now appears on the workbench canvas:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="323" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_4.png" width="141" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;ADDING THE DESTINATION DATASET&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p&gt;The destination dataset will be our new database table which we will name us_states_population.&amp;#160; Here is the first menu panel that appears when we add a new Destination Dataset:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_31.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_13.png" width="412" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Our first task is to choose the correct output format.&amp;#160; We have two potential choices for SQL Server.&amp;#160; In this case, since the new database table will not have a spatial column, we want the Microsoft SQL Server Non-spatial (MSSQL_ADO) format:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_27.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="187" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_11.png" width="428" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt;&amp;#160; If we chose the Microsoft SQL Server Spatial (MSSQL_SPATIAL) format, the data load would work correctly but would have a spatial column defined in the output table, populated with NULL values.&lt;/em&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;Next, we want to select the &amp;quot;Settings...&amp;quot; button.&amp;#160; This allows us to define our server instance, dataset and authentication.&amp;#160; The use of the term &amp;quot;Dataset&amp;quot; is a bit confusing for database users.&amp;#160; What FME is asking for, in this case, is the database name (in our case, temp_spatial):&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_29.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="249" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_12.png" width="373" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;With the destination defined, hit &amp;quot;OK&amp;quot; to continue...&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_33.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_14.png" width="412" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;FME next asks if you would like to add a new feature type to the dataset.&amp;#160; This can be interpreted as &amp;quot;Would you like to add a new table to the database?&amp;quot;, so we need to answer Yes:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_35.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="182" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_15.png" width="335" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;The Feature Type Properties (a.k.a. Table Properties) panel asks for the Feature Type Name.&amp;#160; We supply the name of the database table to hold the population data: us_states_population&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_37.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="402" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_16.png" width="421" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;We hit OK at this point and the destination end point appears on the workbench canvas:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_39.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="332" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_17.png" width="333" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Next, we connect the source and the destination and the upper connection triangles turn green, indicating success.&amp;#160; Now, right click on the destination data and choose &amp;quot;Copy Attributes From Feature Type...&amp;quot;: &lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_15.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="342" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb.png" width="540" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;The Copy Attributes menu panel will now display.&amp;#160; Choose, &amp;quot;Copy Attributes From:&amp;quot;&amp;#160; the only option will be the correction option, in this case:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_19.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="113" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_1.png" width="432" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;The workbench canvas now appears as follows.&amp;#160; It is unclear why FME choose to rename the STATE column but it did (to STATE00).&amp;#160; This causes the implicit connections between source and destination columns to be undefined (yellow connection triangle on source and red connection triangle on the destination).&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_21.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="324" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_7.png" width="330" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;To associate the STATE (source) and STATE00 (destination) columns, drag a line between the two:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_25.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="329" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_10.png" width="343" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;The final task is to check the data types and definitions associated with each column.&amp;#160; Here are the original definitions:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_41.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="474" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_18.png" width="422" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;The SUMLEV and STATE00 columns are both defined as float.&amp;#160; While we are not interested in the SUMLEV column, the STATE00 column needs to be defined as char 2 for compatibility with the STATEFP column in the us_states table, to which we will join this table later on:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_18.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="472" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_A471/image_thumb_8.png" width="427" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;LOAD THE STATES POPULATION DATA&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p&gt;Execute the FME workspace to load the data into a SQL Server table, us_states_population.&amp;#160; The last step is to rename the STATE00 to STATE in Management Studio.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;We are now ready to create our first map report in the Report Builder.&amp;#160; This will be described in Part 5.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1849e6c5-c7eb-4a15-9276-f9526605e86d" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Non-spatial" rel="tag"&gt;Non-spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/data" rel="tag"&gt;data&lt;/a&gt;,&lt;a href="http://technorati.com/tags/population" rel="tag"&gt;population&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Census" rel="tag"&gt;Census&lt;/a&gt;,&lt;a href="http://technorati.com/tags/loading" rel="tag"&gt;loading&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Safe%20Software" rel="tag"&gt;Safe Software&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FME%202010%20Beta" rel="tag"&gt;FME 2010 Beta&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FME" rel="tag"&gt;FME&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Feature%20Manipulation%20Engine" rel="tag"&gt;Feature Manipulation Engine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/non-spatial" rel="tag"&gt;non-spatial&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9624800" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 3</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/05/16/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-3.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/05/16/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-3.aspx</id><published>2009-05-16T17:04:54Z</published><updated>2009-05-16T17:04:54Z</updated><content type="html">&lt;p&gt;In the previous posts we have covered items 1,2 and 3 of the workflow.&amp;#160; In this post we address item 4.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Locate data source and download (Part 1) &lt;/li&gt;    &lt;li&gt;Load the data into SQL Server (Part 1) &lt;/li&gt;    &lt;li&gt;Remove unwanted features, simplify Alaska and Hawaii spatial features (Part 2) &lt;/li&gt;    &lt;li&gt;&lt;u&gt;&lt;strong&gt;&amp;quot;Reposition&amp;quot; Alaska and Hawaii cartographically&lt;/strong&gt;&lt;/u&gt; &lt;/li&gt;    &lt;li&gt;Use the data in the new SQL Server Report Builder &lt;/li&gt; &lt;/ol&gt;  &lt;h3&gt;SQL SERVER SPATIAL TOOLS ON CODEPLEX&lt;/h3&gt;  &lt;p&gt;Now that we have our spatial data suitably prepared, we need to move the Alaska and Hawaii spatial features to new locations.&amp;#160; In order to do this, we need the help of a new function which we have published on the &lt;a href="http://sqlspatialtools.codeplex.com/Wiki/View.aspx?title=Current%20Contents" target="_blank"&gt;SQL Server Spatial Tools&lt;/a&gt; site at &lt;a href="http://www.codeplex.com/" target="_blank"&gt;CodePlex.com&lt;/a&gt;.&amp;#160; This function, AffineTransform, is one of several new functions, aggregates and data types which we have made available with source code. It is beyond the scope of this post to describe SQL Server Spatial Tools, but if you are not familiar with it, you should take a look.&lt;/p&gt;  &lt;h3&gt;REGISTERING THE SQL SPATIAL TOOLS ASSEMBLY&lt;/h3&gt;  &lt;p&gt;SQL Spatial Tools is delivered as an assembly (SQLSpatialTools.dll) which must be registered on the database you wish to use. The registration process is delivered as a register.sql file which needs two modifications (in red) before it is run:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;-- Insert your database      &lt;br /&gt;use [&lt;font color="#ff0000"&gt;Your_Database&lt;/font&gt;]       &lt;br /&gt;go &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;-- Enable CLR      &lt;br /&gt;sp_configure 'clr enabled', 1       &lt;br /&gt;reconfigure       &lt;br /&gt;go &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;-- Insert the path to the SQLSpatialTools assesmbly here      &lt;br /&gt;create assembly SQLSpatialTools from &lt;font color="#ff0000"&gt;'C:\Apps\SQLSpatialTools.dll'&lt;/font&gt;       &lt;br /&gt;go&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;...&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;REPOSITIONING ALASKA AND HAWAII, PASS 1&lt;/h3&gt;  &lt;p&gt;With SQL Server Spatial Tools registered to your database, the AffineTransform function is now available for use in T-SQL.&amp;#160; The AffineTransform is a static function with 3 parameters: Translate, Scale and Rotate.&amp;#160; Setting the initial values for these parameters, especially scale and rotate is based on an educated guess.&amp;#160; The Scale and Translate parameters are addressable via independent X and Y component values.&amp;#160; The Rotate parameter has a single value, with positive numbers rotating the object in a counter-clockwise direction, negative numbers in a clockwise direction.&amp;#160; Displaying the grid lines (Show grid lines in Management Studio) can be used to assist in setting the X and Y Translate values.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="463" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_thumb_3.png" width="633" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is the T-SQL for&amp;#160; the first pass at repositioning Alaska and Hawaii: &lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;USE [&lt;em&gt;Your_Database&lt;/em&gt;]       &lt;br /&gt;GO &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Reposition Alaska       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;DECLARE @a GEOMETRY       &lt;br /&gt;SELECT @a = GEOM FROM us_states_inset2 WHERE STUSPS = 'AK'       &lt;br /&gt;SET @a = AffineTransform::Translate(-1500000, -2500000).Apply(@a)       &lt;br /&gt;SET @a = AffineTransform::Scale(.75, .75).Apply(@a)       &lt;br /&gt;SET @a = AffineTransform::Rotate(15).Apply(@a) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Reposition Hawaii       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;DECLARE @h GEOMETRY       &lt;br /&gt;SELECT @h = GEOM FROM us_states_inset2 WHERE STUSPS = 'HI'       &lt;br /&gt;SET @h = AffineTransform::Translate(2500000, -400000).Apply(@h)      &lt;br /&gt;SET @h = AffineTransform::Scale(2, 2).Apply(@h)       &lt;br /&gt;SET @h = AffineTransform::Rotate(15).Apply(@h)&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Display Original and Repositioned Features       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;SELECT @a -- Repositioned Alaska       &lt;br /&gt;UNION ALL       &lt;br /&gt;SELECT @h -- Repositioned Hawaii       &lt;br /&gt;UNION ALL       &lt;br /&gt;SELECT GEOM FROM us_states_inset2 -- Original Feature Positions       &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The red arrows show the displacement of the Alaska and Hawaii features, after the first pass, below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="439" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_thumb.png" width="501" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;REPOSITIONING ALASKA AND HAWAII, PASS &amp;quot;n&amp;quot;&lt;/h3&gt;  &lt;p&gt;I'd like to say that I was able to achieve final positioning of Alaska and Hawaii in 2 passes but it did take a few more iterations.&amp;#160; Here is the T-SQL for my final pass, achieving the desired positioning of Alaska and Hawaii:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;USE [&lt;em&gt;Your_Database&lt;/em&gt;]       &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Reposition Alaska       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;DECLARE @a GEOMETRY       &lt;br /&gt;SELECT @a = GEOM FROM us_states_inset WHERE STUSPS = 'AK'       &lt;br /&gt;SET @a = AffineTransform::Translate(-1500000, -4500000).Apply(@a)       &lt;br /&gt;SET @a = AffineTransform::Scale(.5, .5).Apply(@a)       &lt;br /&gt;SET @a = AffineTransform::Rotate(27).Apply(@a)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Reposition Hawaii       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;DECLARE @h GEOMETRY       &lt;br /&gt;SELECT @h = GEOM FROM us_states_inset WHERE STUSPS = 'HI'       &lt;br /&gt;SET @h = AffineTransform::Translate(5000000, -400000).Apply(@h)       &lt;br /&gt;SET @h = AffineTransform::Scale(1.5, 1.5).Apply(@h)       &lt;br /&gt;SET @h = AffineTransform::Rotate(30).Apply(@h)&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Display Original and Repositioned Features       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;SELECT @a -- Repositioned Alaska       &lt;br /&gt;UNION ALL       &lt;br /&gt;SELECT @h -- Repositioned Hawaii       &lt;br /&gt;UNION ALL       &lt;br /&gt;SELECT GEOM FROM us_states_inset -- Original Feature Positions       &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The original location and the final repositioned location of Alaska and Hawaii are shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="353" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_thumb_1.png" width="440" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h3&gt;UPDATE FINAL POSITIONS IN THE TABLE &lt;/h3&gt;  &lt;p&gt;With Alaska and Hawaii in final position, the last step is to update the geometry columns (GEOM) for the Alaska and Hawaii rows with the new geometry values:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Reposition Alaska       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;DECLARE @a GEOMETRY       &lt;br /&gt;SELECT @a = GEOM FROM us_states_inset WHERE STUSPS = 'AK'       &lt;br /&gt;SET @a = AffineTransform::Translate(-1500000, -4500000).Apply(@a)       &lt;br /&gt;SET @a = AffineTransform::Scale(.5, .5).Apply(@a)       &lt;br /&gt;SET @a = AffineTransform::Rotate(27).Apply(@a) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Reposition Hawaii       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;DECLARE @h GEOMETRY       &lt;br /&gt;SELECT @h = GEOM FROM us_states_inset WHERE STUSPS = 'HI'       &lt;br /&gt;SET @h = AffineTransform::Translate(5000000, -400000).Apply(@h)       &lt;br /&gt;SET @h = AffineTransform::Scale(1.5, 1.5).Apply(@h)       &lt;br /&gt;SET @h = AffineTransform::Rotate(30).Apply(@h)&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Update Alaska Geometry Instance With New Position       &lt;br /&gt;----------------------------------------------------------------       &lt;br /&gt;UPDATE us_states_inset       &lt;br /&gt;&amp;#160; SET GEOM = @a       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE STUSPS = 'AK' &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;----------------------------------------------------------------      &lt;br /&gt;-- Update Hawaii Geometry Instance With New Position       &lt;br /&gt;----------------------------------------------------------------&amp;#160; &lt;br /&gt;UPDATE us_states_inset       &lt;br /&gt;&amp;#160; SET GEOM = @h       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; WHERE STUSPS = 'HI'&lt;/font&gt;&lt;/p&gt; &lt;font face="Courier New"&gt;----------------------------------------------------------------    &lt;br /&gt;-- Display Table     &lt;br /&gt;----------------------------------------------------------------     &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;SELECT * FROM us_states_inset&lt;/font&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="378" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_11D00/image_thumb_2.png" width="526" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;And there you have it - Alaska and Hawaii neatly tucked under the southwest states, ready for use in the new mapping function in SQL Server Reporting Services.&amp;#160; &lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:25e8db9d-cfc6-4ee8-850c-28381b526a54" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/CodePlex" rel="tag"&gt;CodePlex&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Sever%20Spatial%20Tools" rel="tag"&gt;SQL Sever Spatial Tools&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Affine" rel="tag"&gt;Affine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Transformation" rel="tag"&gt;Transformation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Transform" rel="tag"&gt;Transform&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9622978" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 1</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/05/09/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-1.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/05/09/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-1.aspx</id><published>2009-05-10T07:35:13Z</published><updated>2009-05-10T07:35:13Z</updated><content type="html">&lt;p&gt;I was recently presented with the problem of taking a US States dataset, in geographic coordinates, and creating a database table whose spatial column would render in a similar fashion to the map, below, with the Alaska and Hawaii insets.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="340" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_1.png" width="520" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The ultimate goal was to use the resulting table in the new map control of the upcoming Report Builder in SQL Server Reporting Services (SSRS).&lt;/p&gt;  &lt;h3&gt;APPROACH&lt;/h3&gt;  &lt;p&gt;To illustrate how do this, I choose to use Safe Software's Feature Manipulation Engine (FME 2010 Beta) and SQL Server 2008.&amp;#160; Safe Software aficionados will point out that this could have been done completely in FME. Likewise, this also could have been done completely in SQL Server 2008, though it would have been much more difficult. The use of both tools to solve this problem represents a reasonable real-world approach.&lt;/p&gt;  &lt;h3&gt;WORKFLOW&lt;/h3&gt;  &lt;p&gt;Here is the basic workflow:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Locate data source and download &lt;/li&gt;    &lt;li&gt;Load the data into SQL Server &lt;/li&gt;    &lt;li&gt;Remove unwanted features, simplify Alaska and Hawaii spatial features&amp;#160; &lt;/li&gt;    &lt;li&gt;&amp;quot;Reposition&amp;quot; Alaska and Hawaii cartographically &lt;/li&gt;    &lt;li&gt;Use the data in the new SQL Server Report Builder &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In this post we will cover workflow items 1 and 2.&amp;#160; In subsequent post we will address the other workflow items.&lt;/p&gt;  &lt;h3&gt;DATA SOURCE&lt;/h3&gt;  &lt;p&gt;The original data came from the US Census Bureau's collection of geographic data: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a title="http://www2.census.gov/geo/tiger/TIGER2008/" href="http://www2.census.gov/geo/tiger/TIGER2008/"&gt;http://www2.census.gov/geo/tiger/TIGER2008/&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Specifically, the data was the Tiger Line 2008 US State ShapeFile (&lt;font face="Courier New"&gt;tl_2008_us_state)&lt;/font&gt; found at:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a title="http://www2.census.gov/geo/tiger/TIGER2008/tl_2008_us_state.zip" href="http://www2.census.gov/geo/tiger/TIGER2008/tl_2008_us_state.zip"&gt;http://www2.census.gov/geo/tiger/TIGER2008/tl_2008_us_state.zip&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here is how the input Shapefile appears in the FME Universal Viewer:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_6.png"&gt;&lt;img height="454" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_2.png" width="604" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;DATA LOADING&lt;/h3&gt;  &lt;p&gt;Data loading was accomplished using the FME Workbench, using the following procedure:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Identify the tl_2008_us_state.shp Shapefile as the input data source &lt;/li&gt;    &lt;li&gt;Project the spatial data into an Albers Equal Area projection suitable for the conterminous United States &lt;/li&gt;    &lt;li&gt;Writing the data to a SQL Server 2008 table using the geometry data type &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Add a data source (Source Data), specifying the format as ESRI Shape, the dataset as tl_2008_us_state.shp and the coordinate system as EPSG: 4269 (NAD 83).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_3.png" width="412" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;For visual appeal, an Albers Equal Area projection is chosen using the ESRIReprojector transformer.&amp;#160; I wanted to use the Reprojector transformer but, to date, have not figured out how to locate an existing projection for the North America (-96 central meridian, etc.). &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_12.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="271" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_4.png" width="433" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;No we get to the important part - SQL Server Spatial, our format for the Destination Dataset.&amp;#160; Choose settings, next.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_14.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_5.png" width="412" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The setting menu panel allows you to setup the database connection and specify the output spatial column and name:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_16.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="335" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_6.png" width="373" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Selecting OK bring you back to the Add Destination Dataset where you can select OK to move on...&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_18.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_7.png" width="412" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I always find this next part in FME a wee bit confusing, but before we get into that, answer &amp;quot;Yes&amp;quot; to this menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_20.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="182" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_8.png" width="335" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160; When FME asks, in a database context, if you would like to add a new feature type to the data set, what is really trying to say is, &amp;quot;what would like to name the new database table?&amp;quot;.&amp;#160; In this case our new table table (FME Feature Type Name) will be set to us_states.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_22.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="402" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_9.png" width="421" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Hit &amp;quot;OK&amp;quot; and we now can see the (almost) completed FME workspace.&amp;#160; Note that the destination end point is not yet &amp;quot;connected&amp;quot; to the Shapefile attribute data.&amp;#160; You can tell this by the yellow connector on the ESRIReprojector transformer and the fact that no attributes are list below destination endpoint:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_24.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="195" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_10.png" width="484" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Right-clicking on the destination endpoint brings up a contextual menu which provides a number of choices.&amp;#160; You want the &amp;quot;Copy Attributes From Feature Type&amp;quot; option:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_26.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="314" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_11.png" width="665" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In this case, you have only one choice and it's the correct one (what a coincidence&amp;#160; ;-):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_28.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="113" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_12.png" width="411" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The workflow is now complete and the data load sequence is ready to run:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_30.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="196" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_13.png" width="485" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;To run the workflow, select the green triangle &amp;quot;run&amp;quot; button from the FME menu:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_40.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="162" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_18.png" width="334" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;During the run process, FME writes out all actions to a log file and displays the log to the screen.&amp;#160; In this case, the log noted the following:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;MS SQL Server (Spatial) Writer: Failed to write SRID because the feature's coordinate system could not be converted to an EPSG number&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Let's take a look at the new table, us_states, in SQL Server Management Studio, to see how the SRID value is treated.&amp;#160; Here is how the spatial data displays using the &amp;quot;Spatial results&amp;quot; tab after a &lt;font face="Courier New"&gt;SELECT * FROM us_states&lt;/font&gt; query:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_32.png"&gt;&lt;img height="290" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_14.png" width="575" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;To check the SRID values of each geometry instance we can use the following query:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;SELECT geom.STSrid AS SRID FROM us_states&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_36.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="322" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_B917/image_thumb_16.png" width="411" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;From this we can ascertain that when FME cannot figure out the proper EPSG-based SRID to assign to geometry instances, it does nothing and allows SQL Server to use its default SRID value of 0. &lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:57af7f08-c800-472a-a8be-3651509bbf06" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/spatial" rel="tag"&gt;spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Safe%20Software" rel="tag"&gt;Safe Software&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Feature%20Manipulation%20Engine" rel="tag"&gt;Feature Manipulation Engine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FME" rel="tag"&gt;FME&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Universal%20Viewer" rel="tag"&gt;Universal Viewer&lt;/a&gt;,&lt;a href="http://technorati.com/tags/data%20loading" rel="tag"&gt;data loading&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Shapefile" rel="tag"&gt;Shapefile&lt;/a&gt;,&lt;a href="http://technorati.com/tags/shape%20file" rel="tag"&gt;shape file&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SRID" rel="tag"&gt;SRID&lt;/a&gt;,&lt;a href="http://technorati.com/tags/EPSG" rel="tag"&gt;EPSG&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9600046" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry><entry><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 2</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/edkatibah/archive/2009/05/09/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-2.aspx" /><id>http://blogs.msdn.com/b/edkatibah/archive/2009/05/09/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-2.aspx</id><published>2009-05-10T07:29:32Z</published><updated>2009-05-10T07:29:32Z</updated><content type="html">&lt;p&gt;In the previous post we covered items 1 and 2 of the workflow.&amp;#160; In this post, we will cover item 3:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Locate data source and download &lt;/li&gt;    &lt;li&gt;Load the data into SQL Server &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;&lt;u&gt;Remove unwanted features, simplify Alaska and Hawaii spatial features&lt;/u&gt;&lt;/strong&gt;&amp;#160;&lt;/li&gt;    &lt;li&gt;&amp;quot;Reposition&amp;quot; Alaska and Hawaii cartographically &lt;/li&gt;    &lt;li&gt;Use the data in the new SQL Server Report Builder &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;The challenge now is to remove unwanted spatial features which are not relevant to the Reporting Services map we want to create.&amp;#160; Additionally, we will simplify the Alaska and Hawaii spatial features.&lt;/p&gt;  &lt;p&gt;Let's define the features that we wish to complete remove:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;American Samoa &lt;/li&gt;    &lt;li&gt;Commonwealth of the Northern Mariana Islands &lt;/li&gt;    &lt;li&gt;Virgin Islands of the United States &lt;/li&gt;    &lt;li&gt;Guam &lt;/li&gt;    &lt;li&gt;Puerto Rico &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To remove these features, we will use standard T-SQL queries:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;DELETE FROM us_states WHERE NAME = 'American Samoa'      &lt;br /&gt;DELETE FROM us_states WHERE NAME = 'Commonwealth of the Northern Mariana Islands'       &lt;br /&gt;DELETE FROM us_states WHERE NAME = 'Virgin Islands of the United States'       &lt;br /&gt;DELETE FROM us_states WHERE NAME = 'Guam'       &lt;br /&gt;DELETE FROM us_states WHERE NAME = 'Puerto Rico'       &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Now that we are done with the mundane, let's look at the interesting problem of taking the Alaska and Hawaii spatial features and simplifying them by removing the of out lying islands in the Aleutian Islands and the Hawaiian archipelago. The image, below, shows the features we wish to remove:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="363" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_thumb_1.png" width="511" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This sounds simple enough until we realize that the Alaska and Hawaii spatial features are multipolygons and the features that we want to remove are part of the geometry instances. To make these features accessible, we have to separate the multipolygons into their individual polygon components. To do this we will use FME, both the Workbench and the Universal Viewer.&amp;#160; Here is the workflow:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="302" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_thumb_4.png" width="502" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The data source is the us_states database table.&amp;#160; An AttributeFilter transformer is specified to isolate the Hawaii multipolygon based on the STUSPS attribute:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_12.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="156" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_thumb_5.png" width="369" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The output of the AttributeFilter is then sent to a Deaggregator transformer to separate the Hawaii multipolygon into individual polygons.&amp;#160; The output from the Deaggregator transformer is sent to a Visualizer, below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="576" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_thumb_3.png" width="530" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the Visualizer, we can identify each unique polygon which makes up the Hawaii spatial feature using the FME attribute, _part_number.&amp;#160; Using this approach, we determined that we want to keep _part_numbers 1,2,3,4,6 and 7.&lt;/p&gt;  &lt;p&gt;The Alaska problem is the reverse since there are so many parts to the multipolygon.&amp;#160; In this case we will identify the polygons which we want to remove: _part_numbers 22, 18, 37, 29, 6, 12, 27, 31, 10, 48, 47, 13, 28, 9, 17, 3, 34, 39 and 44.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_20.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="833" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_thumb_9.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This workflow takes the separated (disaggregated) Hawaii and Alaska multipolygons and applies attribute filter transformers to identify specific component polygon elements.&amp;#160; For the Hawaii sub-flow, the new RangeFilter transformer (FME 2010 beta) is used since polygon parts could be easily identified by two ranges.&amp;#160; For the Alaska sub-flow, the polygon components to be removed are listed in the AttributeFilter transformer.&amp;#160; The &amp;lt;UNFILTERED&amp;gt; channel is then chosen, returning the remaining Alaska polygon components.&amp;#160; For both sub-flows, a final Aggregator transformer is used to reassemble the polygon components into multipolygon instances.&amp;#160; All 3 sub-flows (Alaska, Hawaii and &amp;lt;UNFILTERED&amp;gt;) from the first AttributeFilter are channeled to the output database table, us_states_inset.&amp;#160; This new table with the simplified Alaska and Hawaii spatial features is illustrated below from SQL Server Management Studio:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_18.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="414" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/CartographicAdjustmentofSpatialDataforSQ_12BC5/image_thumb_8.png" width="528" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;With the spatial features suitably simplified, we are now ready for the next step, &amp;quot;repositioning&amp;quot; the Alaska and Hawaii spatial features as insets.&amp;#160; This will be described in Part 3.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5773097e-0630-436d-9233-25cadb8e32b4" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SQL%20Server" rel="tag"&gt;SQL Server&lt;/a&gt;,&lt;a href="http://technorati.com/tags/2008" rel="tag"&gt;2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Feature%20Manipulation%20Engine" rel="tag"&gt;Feature Manipulation Engine&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FME" rel="tag"&gt;FME&lt;/a&gt;,&lt;a href="http://technorati.com/tags/AttributeFilter" rel="tag"&gt;AttributeFilter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/RangeFilter" rel="tag"&gt;RangeFilter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Disaggregator" rel="tag"&gt;Disaggregator&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Aggregator" rel="tag"&gt;Aggregator&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Transformer" rel="tag"&gt;Transformer&lt;/a&gt;,&lt;a href="http://technorati.com/tags/FME%202010%20Beta" rel="tag"&gt;FME 2010 Beta&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9600036" width="1" height="1"&gt;</content><author><name>Spatial Ed</name><uri>http://blogs.msdn.com/EdKatibah/ProfileUrlRedirect.ashx</uri></author><category term="Spatial" scheme="http://blogs.msdn.com/b/edkatibah/archive/tags/Spatial/" /></entry></feed>