<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Spatial Ed</title><link>http://blogs.msdn.com/edkatibah/default.aspx</link><description>Information and news on SQL Server Spatial and environs...</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>My Overheating IBM ThinkPad T60p Laptop</title><link>http://blogs.msdn.com/edkatibah/archive/2009/11/13/my-overheating-ibm-t60p-laptop.aspx</link><pubDate>Fri, 13 Nov 2009 22:27:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9922282</guid><dc:creator>EdKatibah</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9922282.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9922282</wfw:commentRss><description>&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;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;</description></item><item><title>A Spatially-Enabled Dinner In Austin, Texas: Some Observations Outside the Office</title><link>http://blogs.msdn.com/edkatibah/archive/2009/10/07/a-spatially-enabled-dinner-in-austin-texas-some-observations-outside-the-office.aspx</link><pubDate>Wed, 07 Oct 2009 19:02:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9904419</guid><dc:creator>EdKatibah</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9904419.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9904419</wfw:commentRss><description>&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;</description></item><item><title>Working with Invalid Data and the SQL Server 2008 Geography Data Type, Part 2</title><link>http://blogs.msdn.com/edkatibah/archive/2009/06/05/working-with-invalid-data-and-the-sql-server-2008-geography-data-type-part-2.aspx</link><pubDate>Sat, 06 Jun 2009 08:09:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9702548</guid><dc:creator>EdKatibah</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9702548.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9702548</wfw:commentRss><description>&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;</description></item><item><title>Update to the SQL Server Spatial Tools project on CodePlex</title><link>http://blogs.msdn.com/edkatibah/archive/2009/06/05/update-to-the-sql-server-spatial-tools-project-on-codeplex.aspx</link><pubDate>Fri, 05 Jun 2009 20:15:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9701665</guid><dc:creator>EdKatibah</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9701665.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9701665</wfw:commentRss><description>&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;</description></item><item><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 5</title><link>http://blogs.msdn.com/edkatibah/archive/2009/05/18/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-5.aspx</link><pubDate>Tue, 19 May 2009 01:27:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9626257</guid><dc:creator>EdKatibah</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9626257.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9626257</wfw:commentRss><description>&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;</description></item><item><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 4</title><link>http://blogs.msdn.com/edkatibah/archive/2009/05/17/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-4.aspx</link><pubDate>Mon, 18 May 2009 07:53:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9624800</guid><dc:creator>EdKatibah</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9624800.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9624800</wfw:commentRss><description>&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;</description></item><item><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 3</title><link>http://blogs.msdn.com/edkatibah/archive/2009/05/16/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-3.aspx</link><pubDate>Sat, 16 May 2009 17:04:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9622978</guid><dc:creator>EdKatibah</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9622978.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9622978</wfw:commentRss><description>&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;</description></item><item><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 1</title><link>http://blogs.msdn.com/edkatibah/archive/2009/05/09/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-1.aspx</link><pubDate>Sun, 10 May 2009 07:35:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9600046</guid><dc:creator>EdKatibah</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9600046.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9600046</wfw:commentRss><description>&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;</description></item><item><title>"Cartographic Adjustment" of Spatial Data for SQL Server Reporting Services, Part 2</title><link>http://blogs.msdn.com/edkatibah/archive/2009/05/09/cartographic-adjustment-of-spatial-data-for-sql-server-reporting-services-part-2.aspx</link><pubDate>Sun, 10 May 2009 07:29:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9600036</guid><dc:creator>EdKatibah</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9600036.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9600036</wfw:commentRss><description>&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;</description></item><item><title>Address Geocoding With SQL Server 2008 Spatial</title><link>http://blogs.msdn.com/edkatibah/archive/2009/03/10/address-geocoding-with-sql-server-2008-spatial.aspx</link><pubDate>Tue, 10 Mar 2009 20:22:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9469363</guid><dc:creator>EdKatibah</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9469363.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9469363</wfw:commentRss><description>&lt;p&gt;In his new book, &lt;a href="http://www.apress.com/book/view/1430218290" target="_blank"&gt;Beginning Spatial with SQL Server 2008&lt;/a&gt;, Alastair Aitchison describes how to create a new CLR-based geocoding T-SQL function utilizing the &lt;a href="http://www.microsoft.com/virtualearth/platform/mappoint.aspx" target="_blank"&gt;MapPoint Web Service&lt;/a&gt;.&amp;#160; Additionally, there is an &lt;a href="http://msdn.microsoft.com/en-us/library/ms141026.aspx" target="_blank"&gt;SSIS&lt;/a&gt;-based &lt;a href="http://mappointbatchgeocode.codeplex.com/" target="_blank"&gt;MapPoint Batch Geocoder&lt;/a&gt; for SQL Server 2008 which also uses the MapPoint Web Service. The MapPoint Web Service, as the name implies, requires an Internet connection.&amp;#160; But, what if your SQL Server 2008 instance is not connected to the Internet? &lt;a href="http://www.yurisw.com/about.htm" target="_blank"&gt;Yuri Software&lt;/a&gt; has a server-based offering, which allows an address geocoding server to be configured for your intranet environment.&amp;#160; This service, &lt;a href="http://www.yurisw.com/YAddress.htm" target="_blank"&gt;YAddress&lt;/a&gt;, offers US-based address geocoding and address data cleansing (address correction, validation and standardization) without the need for an Internet connection.&lt;/p&gt;  &lt;p&gt;Yuri Software has created two SQL Server-compatible geocoding functions which have been released on &lt;a href="http://yaddressudf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22463" target="_blank"&gt;CodePlex&lt;/a&gt;.&amp;#160; In order to make these functions usable in a test environment, Yuri Software has create a web service to which these functions connect.&amp;#160; In a production environment, a high performance local YAddress server would be used. Each of these functions is described, below, along with simple T-SQL coding examples.&lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;ProcessAddress&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;The ProcessAddress function is the first of the YAddress geocoding implementations for SQL Server.&amp;#160; Executing the following T-SQL illustrates the values returned by YAddress:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT * FROM ProcessAddress('3641 Mt Diablo Blvd', 'Lafayette, CA')&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;ErrorCode:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0&amp;#160; &lt;br /&gt;ErrorMessage:&amp;#160; &lt;br /&gt;AddressLine1:&amp;#160;&amp;#160; 3641 MT DIABLO BLVD        &lt;br /&gt;AddressLine2:&amp;#160;&amp;#160; LAFAYETTE, CA 94549-9998        &lt;br /&gt;Number:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3641         &lt;br /&gt;PreDir:         &lt;br /&gt;Street:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MT DIABLO        &lt;br /&gt;Suffix:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BLVD        &lt;br /&gt;PostDir:         &lt;br /&gt;Sec:         &lt;br /&gt;SecNumber:         &lt;br /&gt;City:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LAFAYETTE&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;State:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CA&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Zip:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 94549&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Zip4:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 9998        &lt;br /&gt;County:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CONTRA COSTA&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;CountyFP:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 06-013         &lt;br /&gt;Latitude:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 37.891068        &lt;br /&gt;Longitude:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; -122.126023        &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;PreciseGeocode: 1&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Since this function returns a latitude and longitude value as floating point numbers, it is compatible with both SQL Server 2005 and SQL Server 2008. &lt;/p&gt;  &lt;p&gt;Let's use SQL Server 2008 to construct a geography instance from the latitude and longitude returned from the ProcessAddress function, in this case using the OGC-compliant &lt;font face="Courier New" size="2"&gt;STGeomFromText()&lt;/font&gt; constructor:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @lat FLOAT        &lt;br /&gt;DECLARE @lon FLOAT         &lt;br /&gt;DECLARE @geo GEOGRAPHY         &lt;br /&gt;SELECT @lat = latitude, @lon = longitude FROM ProcessAddress('3641 Mt Diablo Blvd', 'Lafayette, CA')         &lt;br /&gt;SELECT @geo = GEOGRAPHY::STGeomFromText('Point(' + CAST(@lon AS VARCHAR(32)) + ' ' + CAST(@lat AS VARCHAR(32)) + ')',4326)         &lt;br /&gt;SELECT @geo.STAsText()         &lt;br /&gt;GO         &lt;br /&gt;--POINT (-122.126 37.8911)&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;While the &lt;font face="Courier New" size="2"&gt;STGeomFromText()&lt;/font&gt; constructor certainly works, it's an effort to construct the Well-Known Text Point string.&amp;#160; Let's construct the T-SQL using the &lt;font face="Courier New" size="2"&gt;Point()&lt;/font&gt; constructor:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @lat FLOAT        &lt;br /&gt;DECLARE @lon FLOAT         &lt;br /&gt;DECLARE @geo GEOGRAPHY         &lt;br /&gt;SELECT @lat = latitude, @lon = longitude FROM ProcessAddress('3641 Mt Diablo Blvd', 'Lafayette, CA')         &lt;br /&gt;SELECT @geo = GEOGRAPHY::Point(@lat,@lon,4326)         &lt;br /&gt;SELECT @geo.STAsText()         &lt;br /&gt;GO         &lt;br /&gt;--POINT (-122.126023 37.891068)&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This construction is certainly much easier and undoubtedly more performant.&amp;#160; But Yuri Software has another trick up their sleeve - a SQL Server 2008-specific function: ProcessAddress2008.&amp;#160; &lt;/p&gt;  &lt;h4&gt;&lt;strong&gt;ProcessAddress2008&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;ProcessAddress2008() returns a geography instance directly, eliminating the need for the constructor. Here is the full set of data returned from the function:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT * FROM ProcessAddress2008('3641 Mt Diablo Blvd', 'Lafayette, CA')&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;&lt;font face="Courier New" size="2"&gt;ErrorCode:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0&amp;#160; &lt;br /&gt;ErrorMessage:&amp;#160; &lt;br /&gt;AddressLine1:&amp;#160;&amp;#160; 3641 MT DIABLO BLVD      &lt;br /&gt;AddressLine2:&amp;#160;&amp;#160; LAFAYETTE, CA 94549-9998      &lt;br /&gt;Number:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3641       &lt;br /&gt;PreDir:       &lt;br /&gt;Street:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MT DIABLO      &lt;br /&gt;Suffix:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; BLVD      &lt;br /&gt;PostDir:       &lt;br /&gt;Sec:       &lt;br /&gt;SecNumber:       &lt;br /&gt;City:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LAFAYETTE&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;State:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CA&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Zip:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 94549&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;Zip4:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 9998&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;County:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CONTRA COSTA&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;CountyFP:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 06-013       &lt;br /&gt;Location:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0xE6100000010C8D4127840EF24240CEE2C5C210885EC0&lt;/font&gt;    &lt;br /&gt;&lt;font face="Courier New" size="2"&gt;PreciseGeocode: 1&lt;/font&gt;&lt;/blockquote&gt;  &lt;p&gt;The Location field contains an instance of type geography, directly. To show the advantage of this approach, let's construct the same basic query, used in ProcessAddress, above:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @geo GEOGRAPHY&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;        &lt;br /&gt;SELECT @geo = Location FROM ProcessAddress2008('3641 Mt Diablo Blvd', 'Lafayette, CA')         &lt;br /&gt;SELECT @geo.STAsText()         &lt;br /&gt;GO         &lt;br /&gt;--POINT (-122.126023 37.891068)&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;We could be even more concise and achieve the same result:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SELECT Location.STAsText() FROM ProcessAddress2008('3641 Mt Diablo Blvd', 'Lafayette, CA')        &lt;br /&gt;GO         &lt;br /&gt;--POINT (-122.126023 37.891068)&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h4&gt;&lt;strong&gt;Registering The Function&lt;/strong&gt;&lt;/h4&gt;  &lt;p&gt;The last observation surrounds the setup commands used to register the new function with SQL Server.&amp;#160; There are occasions where databases that have been restored from backups do not have the database owner correctly specified.&amp;#160; This issue surfaced while trying to create the assembly from the YAddressSqlFunction.dll:&lt;/p&gt; &lt;font face="Courier New" color="#ff0000" size="2"&gt;The database owner SID recorded in the master database differs from the database owner SID recorded in database 'Sample_Zipcodes'. You should correct this situation by resetting the owner of database 'Sample_Zipcodes' using the ALTER AUTHORIZATION statement.    &lt;br /&gt;Msg 6582, Level 16, State 1, Procedure ProcessAddress, Line 3     &lt;br /&gt;Assembly 'YAddressSqlFunction' is not visible for creating SQL objects. Use ALTER ASSEMBLY to change the assembly visibility.     &lt;br /&gt;&lt;/font&gt;  &lt;p&gt;&amp;#160; In order to ameliorate this issue, use the following stored procedure, setting the database owner to system administrator (sa) before creating the assembly:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New" size="2"&gt;sp_changedbowner 'sa'&lt;/font&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b6cd496d-dd85-4f79-b626-f80e931a6bd9" 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/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/geocoding" rel="tag"&gt;geocoding&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/Yuri%20Software" rel="tag"&gt;Yuri Software&lt;/a&gt;,&lt;a href="http://technorati.com/tags/YAddress" rel="tag"&gt;YAddress&lt;/a&gt;,&lt;a href="http://technorati.com/tags/sp_changedbowner" rel="tag"&gt;sp_changedbowner&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Beginning%20Spatial%20with%20SQL%20Server%202008" rel="tag"&gt;Beginning Spatial with SQL Server 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Alastair%20Aitchison" rel="tag"&gt;Alastair Aitchison&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9469363" width="1" height="1"&gt;</description></item><item><title>Loading GeoNames Data Into SQL Server 2008 (the PowerShell, bcp way...)</title><link>http://blogs.msdn.com/edkatibah/archive/2009/01/20/loading-geonames-data-into-sql-server-2008-the-powershell-bcp-way.aspx</link><pubDate>Tue, 20 Jan 2009 22:56:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9322503</guid><dc:creator>EdKatibah</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9322503.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9322503</wfw:commentRss><description>&lt;p&gt;In the &lt;a href="http://blogs.msdn.com/edkatibah/archive/2009/01/13/loading-geonames-data-into-sql-server-2008-yet-another-way.aspx" target="_blank"&gt;first installment&lt;/a&gt; on this topic, I used a commercial text editor, &lt;a href="http://www.editpadpro.com/" target="_blank"&gt;EditPad Pro&lt;/a&gt;, to perform the Unicode file conversion and SQL Server BULK INSERT to load the data. In this installment, I'm going to change to workflow a bit to use of Microsoft's PowerShell for the Unicode file conversion and bcp (Bulk Copy) to perform the data loading.&amp;#160; Thus, the new workflow is:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Download GeoNames data &lt;/li&gt;    &lt;li&gt;Create a database table for the GeoNames data &lt;/li&gt;    &lt;li&gt;Convert and load the GeoNames data using PowerShell and bcp &lt;/li&gt;    &lt;li&gt;Add, update and index the spatial data column &lt;/li&gt;    &lt;li&gt;Sample spatial query &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;For this post, I'm going to concentrate on step 2.&amp;#160; For the other workflow steps, please refer back to the first installment on this topic, &lt;a href="http://blogs.msdn.com/edkatibah/archive/2009/01/13/loading-geonames-data-into-sql-server-2008-yet-another-way.aspx" target="_blank"&gt;Loading GeoNames Data Into SQL Server 2008 (yet another way...)&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Convert and load the GeoNames data using PowerShell and bcp&lt;/h3&gt;  &lt;p&gt;For this exercise, my colleague, Bob Beauchemin, gave me some very useful guidance.&amp;#160; If you are not familiar with &lt;a href="http://sqlskills.com/blogs/bobb/" target="_blank"&gt;Bob's blog&lt;/a&gt;, it a great place to find a wealth of information about SQL Server.&amp;#160; Bob has special affection for spatial and you can find some very interesting posts on this topic.&lt;/p&gt;  &lt;h4&gt;Install and Configure PowerShell&lt;/h4&gt;  &lt;p&gt;The basis for this solution is the &lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank"&gt;Microsoft Windows PowerShell&lt;/a&gt; command line shell. Being an old UNIX guy, shell scripting was my first inclination when presented with the UTF-8 --&amp;gt; UTF-16 conversion problem.&amp;#160; And I'm happy to say that PowerShell provides and excellent Windows-based shell for doing exactly what is needed. If you've got Windows Server 2008, it's already there.&amp;#160; If you have Windows XP, Windows Vista, or Windows Server 2003, you will need to &lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx" target="_blank"&gt;download&lt;/a&gt; the appropriate version for your platform.&lt;/p&gt;  &lt;p&gt;Once installed, you can fire up PowerShell by issuing the command, powershell, in the command shell (Start-&amp;gt; Run -&amp;gt; Open: cmd).&amp;#160; When loaded, you will get a PS&amp;gt; prompt.&amp;#160; Before we can execute a script, we need to set the script execution policy.&amp;#160; For our humble purposes, we don't need to be bothered by the security considerations which might be demanded in a more public execution environment.&amp;#160; If you decide to put your script into wider use, please do set an execution policy suitable for your environment.&lt;/p&gt;  &lt;p&gt;Try running the following commands:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;PS&amp;gt; Get-ExecutionPolicy      &lt;br /&gt;Restricted&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;PS&amp;gt; Set-ExecutionPolicy Unrestricted&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;PS&amp;gt; Get-ExecutionPolicy      &lt;br /&gt;Unrestricted&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; The execution policy persists between PowerShell sessions, so you only need to set it once.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;To exit PowerShell, type &lt;font face="Courier New" size="2"&gt;exit&lt;/font&gt; at the PowerShell Prompt. To learn more about PowerShell see the &lt;a href="http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/run.mspx" target="_blank"&gt;PowerShell Help Center&lt;/a&gt;. &lt;/p&gt;  &lt;h4&gt;Create PowerShell Script&lt;/h4&gt;  &lt;p&gt;You have now configured PowerShell so that you can easily run the script we are about to describe.&lt;/p&gt;  &lt;p&gt;In this script, we will do the following:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a temporary file name to hold the output from the command which converts the UTF-8 data to UTF-16. &lt;/li&gt;    &lt;li&gt;Execute a command which converts the data from UTF-8 to UTF-16, changes the row terminators to '\r\n' and writes a Unicode signature at the beginning of the converted data (the BOM is described in the previous post). &lt;/li&gt;    &lt;li&gt;Load the converted data file into SQL Server 2008 using the Bulk Copy Program, &lt;a href="http://msdn.microsoft.com/en-us/library/ms162802.aspx" target="_blank"&gt;bcp&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Delete the temporary file &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;All of these operations will be saved as a function which we can run from the PowerShell command line, called convert-and-load.&amp;#160; Here is the PowerShell script:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;&lt;font face="Courier New" size="2"&gt;function convert-and-load { &lt;/font&gt;&amp;#160; &lt;br /&gt;&amp;#160; $tempfile = &amp;quot;$env:temp\TEMP$(Get-Date -format 'yyyyMMddhhmmss').txt&amp;quot;&amp;#160; &lt;br /&gt;&amp;#160; get-content -Path $args[0] &amp;#8211;encoding utf8 | out-file $tempfile -encoding Unicode&amp;#160; &lt;br /&gt;&amp;#160; $serverinstance = $args[2]&amp;#160; &lt;br /&gt;&amp;#160; $serveroption = &amp;quot;-S$serverinstance&amp;quot;&amp;#160; &lt;br /&gt;&amp;#160; bcp $args[1] in $tempfile -w &amp;#8211;T $serveroption&amp;#160; &lt;br /&gt;&amp;#160; del $tempfile         &lt;br /&gt;&amp;#160; }&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;The bcp -w and -T arguments do the following (from &lt;a href="http://msdn.microsoft.com/en-us/library/aa174646.aspx" target="_blank"&gt;MSDN bcp Utility&lt;/a&gt;):&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;-w &lt;/b&gt;Performs the bulk copy operation using Unicode characters. This option does not prompt for each field; it uses &lt;b&gt;nchar&lt;/b&gt;&amp;#160; as the storage type, no prefixes, &lt;b&gt;\&lt;/b&gt;t (tab character) as the field separator, and &lt;b&gt;\&lt;/b&gt;n (newline character) as the row terminator. &lt;em&gt;Note that even though it says \n (newline) for the row terminator, it really means \r\n (carriage return\newline).&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;- &lt;b&gt;T &lt;/b&gt;Specifies that bcp connects to SQL Server with a trusted connection&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The next step is to install this script so that PowerShell recognizes the function.&lt;/p&gt;  &lt;h4&gt;Install PowerShell Script&lt;/h4&gt;  &lt;p&gt;You can install this new function into your PowerShell profile. This profile should be placed in the C:\Documents and Settings\&lt;em&gt;[your Windows login]&lt;/em&gt;\My Documents\WindowsPowerShell folder.&amp;#160; You can name the profile anything you want but it has to have a prefix of .ps1.&amp;#160; I named mine: profile.ps1.&amp;#160; When PowerShell starts up, it reads this file and loads, in this case, our new convert-and-load function.&lt;/p&gt;  &lt;h4&gt;Execute PowerShell Script&lt;/h4&gt;  &lt;p&gt;The new function, &lt;font face="Courier New" size="2"&gt;convert-and-load,&lt;/font&gt; takes 3 arguments: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;UTF-8 filename - &lt;em&gt;e.g.&lt;/em&gt; &lt;em&gt;c:\temp\allCountries.txt&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;fully qualified database table name - &lt;em&gt;e.g. Sample_GeoNames.dbo.GeoNames&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;database server\database instance name - &lt;em&gt;e.g. sqlspatial\ss1600&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is how the command looked in my environment, ready for execution:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;PS&amp;gt; convert-and-load c:\temp\allCountries.txt Sample_GeoNames.dbo.GeoNames sqlspatial\ss1600&lt;/font&gt;&lt;/p&gt;  &lt;h4&gt;UTF-8 to UTF-16 File Conversion Performance&lt;/h4&gt;  &lt;p&gt;The entire convert and load process of the allCountries.txt GeoNames dump (6,906,334 records) took approximately 1 hour and 25 minutes to complete with the UTF-8 to UTF-16 conversion process consuming approximately 1 hour and 5 minutes of that time.&amp;#160; This is comparable to the time it took to perform the same conversion in EditPad Pro from my &lt;a href="http://blogs.msdn.com/edkatibah/archive/2009/01/13/loading-geonames-data-into-sql-server-2008-yet-another-way.aspx" target="_blank"&gt;previous post&lt;/a&gt;.&lt;/p&gt;  &lt;h4&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms162802.aspx" target="_blank"&gt;bcp&lt;/a&gt; Performance&lt;/h4&gt;  &lt;p&gt;I saved the temporary UTF-16 file by removing the &lt;font face="Courier New" size="2"&gt;del $filename&lt;/font&gt; line in the script and ran 3 scenarios to get a better feel for the performance of bcp.&amp;#160; Here are the results:&lt;/p&gt;  &lt;p&gt;Data residing on c: drive (same drive as the database storage): &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;6906334 rows copied.      &lt;br /&gt;Network packet size (bytes): 4096       &lt;br /&gt;Clock Time (ms.) Total: 1112859 Average: (6205.94 rows per second)       &lt;br /&gt;18.55 minutes&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Data residing on e: drive (database storage on c:):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;6906334 rows copied.      &lt;br /&gt;Network packet size (bytes): 4096       &lt;br /&gt;Clock Time (ms.) Total: 1009954 Average: (6838.27 rows per second)       &lt;br /&gt;16.83 minutes&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Data residing on e: drive, increased network packet size: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;6906334 rows copied.      &lt;br /&gt;Network packet size (bytes): 16192       &lt;br /&gt;Clock Time (ms.) Total: 1102265 Average: (6265.58 rows per second)       &lt;br /&gt;18.37 minutes&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are other tuning measures to improve bcp's performance&amp;#160; and we will investigate this for a future post. Compare this with the 5.75 minutes it took to load the same data using the BULK INSERT T-SQL command (see the &amp;quot;Load the GeoNames data&amp;quot; section from my &lt;a href="http://blogs.msdn.com/edkatibah/archive/2009/01/13/loading-geonames-data-into-sql-server-2008-yet-another-way.aspx" target="_blank"&gt;previous post&lt;/a&gt;).&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;While we give up some performance, mainly due to bcp, we do have a more convenient workflow.&amp;#160; It is also important to recognize how bcp and BULK INSERT affect their respective execution environments.&amp;#160; bcp places the computing load on the local client machine.&amp;#160; BULK INSERT, on the other hand, places the load directly on the database server.&amp;#160; If you are trying to minimize load on a busy database server, then bcp may be the best solution. &lt;/p&gt;  &lt;p&gt;In my next installment on this topic I will explore the SQL PowerShell Extensions, providing access to BULK INSERT from within the PowerShell script. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8072f35e-9951-430f-9894-506339c6fbfb" 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/PowerShell" rel="tag"&gt;PowerShell&lt;/a&gt;,&lt;a href="http://technorati.com/tags/bcp" rel="tag"&gt;bcp&lt;/a&gt;,&lt;a href="http://technorati.com/tags/BULK%20INSERT" rel="tag"&gt;BULK INSERT&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/GeoNames" rel="tag"&gt;GeoNames&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/SQL%20Server%202008" 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/UTF-8" rel="tag"&gt;UTF-8&lt;/a&gt;,&lt;a href="http://technorati.com/tags/UTF-16" rel="tag"&gt;UTF-16&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Unicode" rel="tag"&gt;Unicode&lt;/a&gt;&lt;/div&gt; &lt;font face="Courier New" size="2"&gt;&lt;/font&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9322503" width="1" height="1"&gt;</description></item><item><title>Loading GeoNames Data Into SQL Server 2008 (yet another way...)</title><link>http://blogs.msdn.com/edkatibah/archive/2009/01/13/loading-geonames-data-into-sql-server-2008-yet-another-way.aspx</link><pubDate>Wed, 14 Jan 2009 02:05:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9317454</guid><dc:creator>EdKatibah</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9317454.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9317454</wfw:commentRss><description>&lt;p&gt;In his post last year, &lt;a href="http://johanneskebeck.spaces.live.com/Blog/cns!42E1F70205EC8A96!3782.entry" target="_blank"&gt;Integrating Virtual Earth and GeoNames&lt;/a&gt;, Johannes described how to load the &lt;a href="http://www.geonames.org/about.html" target="_blank"&gt;GeoNames&lt;/a&gt; database into SQL Server using the &amp;quot;Import Data&amp;quot; Wizard in SQL Server Management Studio. In his scenario, Johannes did not need to take advantage of the spatial type support in SQL Server 2008, since there were columns of latitude and longitude available for use by Virtual Earth.&amp;#160; But what if you wanted to load the GeoNames locations into SQL Server Spatial and use the new geospatial features?&amp;#160; This post describes how to do that in 6 easy steps...&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Download GeoNames data &lt;/li&gt;    &lt;li&gt;Prepare GeoNames data &lt;/li&gt;    &lt;li&gt;Create a database table for the GeoNames data &lt;/li&gt;    &lt;li&gt;Load the GeoNames data &lt;/li&gt;    &lt;li&gt;Add, update and index the spatial data column &lt;/li&gt;    &lt;li&gt;Sample spatial query &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So, let's get started...&lt;/p&gt;  &lt;h3&gt;Download GeoNames Data&amp;#160; &lt;/h3&gt;  &lt;p&gt;You can find GeoNames data organized by country (and a few other organizational categories) by browsing the &lt;a href="http://download.geonames.org/export/dump/" target="_blank"&gt;GeoNames Download page&lt;/a&gt;. If you wanted to download the GeoNames data for the United States, you would choose &lt;a href="http://download.geonames.org/export/dump/US.zip" target="_blank"&gt;US.zip&lt;/a&gt;.&amp;#160; For this exercise, we are going to download the &lt;a href="http://download.geonames.org/export/dump/allCountries.zip" target="_blank"&gt;allCountries.zip&lt;/a&gt; file, containing the full worldwide GeoNames database.&amp;#160; Unzipping the downloaded file will produce the file allCountries.txt.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; This version of GeoNames data was download on January 13, 2009 and contained 6,906,334 records.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Prepare GeoNames Data&lt;/h3&gt;  &lt;p&gt;The GeoNames data is available as a tab-delimited, 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 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; Johannes introduced &lt;a href="http://nant.sourceforge.net/"&gt;NAnt&lt;/a&gt; as a way to convert UTF-8 data to UTF-16.&amp;#160; I chose another way.&amp;#160; Using the Windows text editor, &lt;a href="http://www.editpadpro.com/" target="_blank"&gt;EditPad Pro&lt;/a&gt;, I converted the allCountries.txt file into a form compatible with SQL Server 2008. Here is the workflow I used with EditPad Pro:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; While this conversion could conceivably be done in Word 2007, Word cannot open and operate &lt;u&gt;efficiently&lt;/u&gt; on files of this size.&amp;#160; EditPad Pro can reasonably handle data of this magnitude.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;a. &lt;strong&gt;Open allCountries.txt file in EditPad Pro.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;b. &lt;strong&gt;Set Record Delimiter.&lt;/strong&gt; In the &amp;quot;Convert&amp;quot; menu (main menu), select &amp;quot;To Windows (CR LF)&amp;quot;.&amp;#160; This will set the record delimiter to '\r\n'.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="352" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_2.png" width="200" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;This took several minutes to complete in EditPad Pro after the &amp;quot;To Windows (CR LF)&amp;quot; option was selected - presumably loading the file into memory and performing the requested operation...&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;c. &lt;strong&gt;Set text encoding.&lt;/strong&gt; While still in the &amp;quot;Convert&amp;quot; menu, choose &amp;quot;Text Encoding&amp;quot;.&amp;#160; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_8.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="352" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_3.png" width="200" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;In the Text Encoding menu note the Original Encoding, set to Unicode, UTF-8.&amp;#160; Select the &amp;quot;Encode the original data with another character set.&amp;quot; button.&amp;#160; Under New Encoding, choose &amp;quot;Unicode, UTF-16 little endian&amp;quot;.&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_4.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/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_1.png" width="585" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;After hitting &amp;quot;OK&amp;quot;, my humble dual proc machine with 2GB of RAM squawked about low virtual memory, but continued to process the file...&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;d. &lt;strong&gt;Set the Byte Order Marker (BOM).&lt;/strong&gt;&amp;#160; In the &amp;quot;Options&amp;quot; menu (main menu), select &amp;quot;Configure File Types...&amp;quot;. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_10.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="326" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_4.png" width="210" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Choose the &amp;quot;Encoding&amp;quot; tab.&amp;#160; Under File Types, make sure &amp;quot;Text Document&amp;quot; is selected. Make sure that the Text Encoding is set as follows:&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_14.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="275" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_6.png" width="555" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note on the Default Line Break Style:&lt;/strong&gt; While it appears that the line break was already set under stop b. (above), it appears that setting the line break in both places is required, though it is not obvious, why...&lt;/em&gt;&lt;/p&gt;   &lt;em&gt;&lt;strong&gt;Note on the Byte Order Marker (BOM):&lt;/strong&gt; You can see the BOM as the FF FE bytes at the &lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_20.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 5px 10px 0px 0px; border-right-width: 0px" height="94" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_9.png" width="163" align="left" border="0" /&gt;&lt;/a&gt; start of the file by pressing Crtl+H in EditPad Pro (this switches EditPad Pro to hex display mode). If your file does not include the BOM, SQL Server will complain, when loading data, that the &amp;quot;...file does not have a Unicode signature.&amp;quot;&lt;/em&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;e.&amp;#160; &lt;strong&gt;Create new file copy, correctly encoded for SQL Server 2008.&lt;/strong&gt; In the &amp;quot;File&amp;quot; menu (main menu), select &amp;quot;Save Copy As...&amp;quot;. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_16.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="417" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_7.png" width="195" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Save the file with the desired name (I used allCountries_utf16.txt):&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_18.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="438" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_8.png" width="592" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The file, allCountries_utf16.txt, is now a Unicode UTF-16, BOM encoded text file with tab-delimited ('\t') fields and CR\LF row terminators ('\r\n'), ready for SQL Server 2008.&lt;/p&gt;  &lt;p&gt;Before we leave this section, here are some statistics:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="400" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="143"&gt;FILE&lt;/td&gt;        &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="243"&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; SIZE&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="147"&gt;allCountries.zip&lt;/td&gt;        &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="243"&gt;&amp;#160;&amp;#160; 174,594 KB&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="150"&gt;allCountries.txt&lt;/td&gt;        &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="243"&gt;&amp;#160;&amp;#160; 783,093 KB&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="153"&gt;allCountries_utf16.txt&lt;/td&gt;        &lt;td valign="top" width="10"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="243"&gt;1,563,976 KB&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;h3&gt;Create a database table for the GeoNames data&lt;/h3&gt;  &lt;p&gt;Here is the T-SQL to create a table called GeoNames...&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;CREATE TABLE GeoNames(        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; geonameid int NOT NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; name nvarchar(200) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; asciiname nvarchar(200) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alternatenames nvarchar(max) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; latitude float NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; longitude float NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; feature_class char(2) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; feature_code nvarchar(10) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; country_code char(3) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cc2 char(60) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; admin1_code nvarchar(20) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; admin2_code nvarchar(80) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; admin3_code nvarchar(20) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; admin4_code nvarchar(20) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; population int NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; elevation int NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; gtopo30 int NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; timezone char(31) NULL,         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; modification_date date NULL         &lt;br /&gt;)         &lt;br /&gt;GO&lt;/font&gt; &lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note on the alternatenames column:&lt;/strong&gt; This column holds the GeoNames field which requires Unicode (UTF-8, UTF-16).&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Load the GeoNames data&lt;/h3&gt;  &lt;p&gt;I used the &lt;a href="http://msdn.microsoft.com/en-us/library/ms188365.aspx" target="_blank"&gt;BULK INSERT&lt;/a&gt; command to load the allCountries_utf16.txt file.&amp;#160; Note the DATAFILETYPE = 'widechar' parameter - this is required for loading UTF-16 data.     &lt;br /&gt;&lt;font size="3"&gt;     &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;BULK      &lt;br /&gt;&amp;#160; INSERT GeoNames       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM 'C:\temp\allCountries_utf16.txt'       &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; WITH(       &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;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATAFILETYPE = 'widechar',       &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;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FIELDTERMINATOR = '\t',       &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;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ROWTERMINATOR = '\n'       &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;&amp;#160;&amp;#160; )       &lt;br /&gt;GO       &lt;br /&gt;--(6906334 rows(s) affected) (00:05:44)&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2"&gt;&lt;em&gt;&lt;strong&gt;Note on the ROWTERMINATOR:&lt;/strong&gt; While I have changed the Row Terminator in the allCountries_utf16.txt file to '\r\n', SQL Server, curiously, requires the Row Terminator to be set to '\n'.&amp;#160; There is no good explanation for this...&lt;/em&gt;&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Add, update and index the spatial data column&lt;/h3&gt;  &lt;p&gt;The current table does not contain a column to hold native spatial data.&amp;#160; Since the data is in WGS84 geographic coordinates, I used the geography data type for the new column:&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;font face="Courier New"&gt;&lt;font size="2"&gt;ALTER TABLE GeoNames          &lt;br /&gt;&amp;#160; ADD geog GEOGRAPHY NULL           &lt;br /&gt;GO&lt;/font&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To populate the new geography column (geog), I used the STGeomFromText constructor to create a POINT feature for each GeoNames row.&amp;#160; Since this is a text-based constructor, the longitude and latitude data, coming from columns of like name, will need to be converted into text using the CAST function.&amp;#160; The SRID for the STGeomFromText constructor is set to 4326, the EPSG value for WGS84 coordinates.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;UPDATE GeoNames      &lt;br /&gt;&amp;#160; SET geog = GEOGRAPHY::STGeomFromText       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;('POINT(' + CAST(longitude AS CHAR(20))&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;+ ' ' + CAST(latitude AS CHAR(20)) + ')',4326)      &lt;br /&gt;GO       &lt;br /&gt;--(6906334 rows(s) affected) (00:09:40)&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note on coordinate order:&lt;/strong&gt; Since this is an OGC-based operator, the WKT is formed as: 'POINT (&amp;lt;longitude&amp;gt; &amp;lt;latitude&amp;gt;)'.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In order to create a spatial index, the table must have a primary key.&amp;#160; While I could have created the primary key in the CREATE TABLE DDL, this would have meant that the data was loaded into an existing index, slowing down the load process considerably.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;ALTER TABLE GeoNames      &lt;br /&gt;&amp;#160; ADD CONSTRAINT pk_geonames_geonameid       &lt;br /&gt;&amp;#160; PRIMARY KEY (geonameid )       &lt;br /&gt;GO&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is the DDL to create a spatial index on the geography column, geog:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;CREATE SPATIAL INDEX geonames_mmmm16_sidx      &lt;br /&gt;&amp;#160;&amp;#160; ON GeoNames(geog)       &lt;br /&gt;&amp;#160;&amp;#160; USING GEOGRAPHY_GRID       &lt;br /&gt;&amp;#160;&amp;#160; WITH (       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; GRIDS = (MEDIUM, MEDIUM, MEDIUM, MEDIUM),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CELLS_PER_OBJECT = 16,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; PAD_INDEX = ON&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;#160;&amp;#160; )      &lt;br /&gt;GO       &lt;br /&gt;--(00:10:30)&lt;/font&gt;&lt;/p&gt;  &lt;h3&gt;Sample spatial query&lt;/h3&gt;  &lt;p&gt;As an example of the type of queries which can now be supported using the GeoNames table, consider the following: &amp;quot;Find all place names within 1 kilometer of the Travis County (Texas) boundary line&amp;quot;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;strong&gt;Note:&lt;/strong&gt; the distance parameter for the STBuffer() method (geography data type) is in meters...&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;DECLARE @g GEOGRAPHY      &lt;br /&gt;DECLARE @h GEOGRAPHY       &lt;br /&gt;DECLARE @i GEOGRAPHY       &lt;br /&gt;DECLARE @j GEOGRAPHY       &lt;br /&gt;SELECT @g = geog FROM US_Counties WHERE NAME = 'Travis'      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--SQL Server Execution Times: Elapsed time = 8 ms&amp;#160; &lt;br /&gt;SELECT @h = @g.STBuffer(1000)&amp;#160; -- Positive buffer around Travis County       &lt;br /&gt;--SQL Server Execution Time: Elapsed time = 16 ms      &lt;br /&gt;SELECT @i = @g.STBuffer(-1000) -- Negative buffer around Travis County      &lt;br /&gt;--SQL Server Execution Time: Elapsed time = 16ms&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;     &lt;br /&gt;SELECT @j = @h.STDifference(@i)-- Difference Polygon      &lt;br /&gt;--SQL Server Execution Time: Elapsed time = 4 ms&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;     &lt;br /&gt;SELECT name FROM GeoNames &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;WHERE geog.STIntersects(@j)=1&amp;#160; &lt;br /&gt;&amp;#160; ORDER BY name ASC       &lt;br /&gt;--91 rows affected       &lt;br /&gt;--SQL Server Execution Time: Elapsed time = 823 ms.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Here is the list of place names returned by the query:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="605" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="173"&gt;         &lt;p&gt;&lt;font size="1"&gt;Anderson Mill              &lt;br /&gt;Anderson Mill Elementary School               &lt;br /&gt;Apple Spring               &lt;br /&gt;Apple Spring Hollow               &lt;br /&gt;Austin Air Ranch Airport               &lt;br /&gt;Austin Raceway Park               &lt;br /&gt;Balcones Country Club               &lt;br /&gt;Balcones Country Club Lake               &lt;br /&gt;Balcones Country Club Lake Dam               &lt;br /&gt;Bear Creek               &lt;br /&gt;Best Western Southgate Inn Ste               &lt;br /&gt;Blessed Juan Diego Catholic Church               &lt;br /&gt;Bonnet Cemetery               &lt;br /&gt;Boultinghouse Mountain               &lt;br /&gt;Bratton Cemetery               &lt;br /&gt;Bridgeway Community Church               &lt;br /&gt;Cambrian Creek               &lt;br /&gt;Canyon Vista Middle School               &lt;br /&gt;Canyon Vista Pool               &lt;br /&gt;Cedar Park High School               &lt;br /&gt;Center Union Church               &lt;br /&gt;Chalk Knob               &lt;br /&gt;Chalk Knob Branch               &lt;br /&gt;Child Evangelism Fellowship Church               &lt;br /&gt;Church of Christ - Pond Springs               &lt;br /&gt;Clarence Washington Farm Dam               &lt;br /&gt;Clarence Washington Farm Lake               &lt;br /&gt;Cottonwood Branch               &lt;br /&gt;Crestwood Suites - Austin               &lt;br /&gt;Cypress Creek Baptist Church&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="19"&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="195"&gt;         &lt;p&gt;&lt;font size="1"&gt;Cypress Elementary School              &lt;br /&gt;Devils Hollow               &lt;br /&gt;Esa Austin-Round Rock-South               &lt;br /&gt;Fall Creek Cemetery               &lt;br /&gt;Fitzhugh               &lt;br /&gt;Fitzhugh Cemetery               &lt;br /&gt;Garfield Pumping Station               &lt;br /&gt;Gateway Community Church               &lt;br /&gt;Gay Hollow               &lt;br /&gt;Hamilton Hill               &lt;br /&gt;Hammetts Crossing               &lt;br /&gt;Hampton Inn Austin Round Rock               &lt;br /&gt;Harris Branch               &lt;br /&gt;Haynie Flat Cemetery               &lt;br /&gt;Hilton Garden Inn Round Rock&amp;#160; &lt;br /&gt;Hope Presbyterian Church               &lt;br /&gt;Huddleston Cemetery               &lt;br /&gt;Ingram Cemetery               &lt;br /&gt;Jollyville               &lt;br /&gt;Jollyville Cemetery               &lt;br /&gt;Jollyville Elementary School               &lt;br /&gt;KGTN-AM (Creedmoor)               &lt;br /&gt;Koenig Ranch               &lt;br /&gt;La Frontera in Round Rock               &lt;br /&gt;La Quinta Inn &amp;amp; Suites Round Rock South               &lt;br /&gt;Manchaca Optimist Youth Sports Complex               &lt;br /&gt;Manchaca Springs               &lt;br /&gt;Marriott Austin North               &lt;br /&gt;Martin Hill               &lt;br /&gt;McNeil&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="18"&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="196"&gt;         &lt;p&gt;&lt;font size="1"&gt;McNeil High School              &lt;br /&gt;Merrelltown               &lt;br /&gt;Muleshoe Bend               &lt;br /&gt;Muleshoe Bend Trail               &lt;br /&gt;New Hope Community Church               &lt;br /&gt;Niederwald Cemetery               &lt;br /&gt;North Creek Park               &lt;br /&gt;Pond Springs               &lt;br /&gt;Presbyterian Church of the Hills               &lt;br /&gt;Purple Sage Elementary School               &lt;br /&gt;Rattan Creek Trail               &lt;br /&gt;Red Bluff Creek               &lt;br /&gt;Residence Inn By Marriott Austin Round Rock               &lt;br /&gt;Rhodes Cemetery               &lt;br /&gt;Rim Rock Trail               &lt;br /&gt;Round Rock Korean Presbyterian Church               &lt;br /&gt;Round Rock Opportunity Center               &lt;br /&gt;Roy Creek               &lt;br /&gt;Saint Vincent de Paul Catholic Church               &lt;br /&gt;Shingle Hills               &lt;br /&gt;Signal Hill               &lt;br /&gt;Spicewood Elementary School               &lt;br /&gt;Spillar Ranch               &lt;br /&gt;Studio 6 Austin Northwest               &lt;br /&gt;Tanglewood Spring               &lt;br /&gt;Texas No Name Number 9 Dam               &lt;br /&gt;The Marbridge School               &lt;br /&gt;Turkey Bend               &lt;br /&gt;Turkey Bend Trail               &lt;br /&gt;Vasquez Cemetery               &lt;br /&gt;Woods Hill&lt;/font&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Here is the visual result of the place names locations, within the county boundary buffer, presented in Management Studio:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_22.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="421" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_10.png" width="477" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here is a more detailed view (the actual point locations are represented by the block dots in the center of each point symbol):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_24.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="419" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/LoadingGeoNamesDataIntoSQLServer2008yet_B2DD/image_thumb_11.png" width="595" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;And there you have it - sub-second performance against 6.9 million rows with a complex spatial object on a very modest machine...&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b090a3e5-2fc2-4f17-b93c-4705365cd898" 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/GeoNames" rel="tag"&gt;GeoNames&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Unicode" rel="tag"&gt;Unicode&lt;/a&gt;,&lt;a href="http://technorati.com/tags/UTF-8" rel="tag"&gt;UTF-8&lt;/a&gt;,&lt;a href="http://technorati.com/tags/UTF-16" rel="tag"&gt;UTF-16&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/Spatial" rel="tag"&gt;Spatial&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/EditPad" rel="tag"&gt;EditPad&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9317454" width="1" height="1"&gt;</description></item><item><title>Where is Ed?</title><link>http://blogs.msdn.com/edkatibah/archive/2008/12/28/where-is-ed.aspx</link><pubDate>Mon, 29 Dec 2008 08:29:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9255356</guid><dc:creator>EdKatibah</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/9255356.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=9255356</wfw:commentRss><description>&lt;p&gt;After a rather lengthy hiatus, I'm back to blogging once again.&amp;#160; I was awakened from my reverie by an old friend who noted that a few folks had wondered if I was still alive and kicking.&amp;#160; Not to worry, I'm still busy with SQL Server Spatial.&amp;#160; But back to the central question: Where is Ed?&amp;#160; &lt;/p&gt;  &lt;p&gt;One of the things I've been up to is working with my colleague Olivier on a little project, not coincidentally named &amp;quot;Where is Ed?&amp;quot; or WiE, for short.&amp;#160; The goal of WiE started simply enough - build an application using off-the-shelf Microsoft technology to track my location, anywhere in the World (well, at least when I was visible to the GPS satellite constellation and had WiE tracking turned on in my Windows Mobile-equipped phone).&lt;/p&gt;  &lt;p&gt;I won't go into a lot of detail about WiE since Olivier has written extensively about it on &lt;a href="http://blogs.msdn.com/oliviermeyer/archive/2008/12/19/wie-project-and-source-code-posted-to-codeplex.aspx" target="_blank"&gt;his blog&lt;/a&gt; and has created a &lt;a href="http://www.codeplex.com/wie" target="_blank"&gt;CodePlex site&lt;/a&gt; from which the underlying code can be downloaded.&amp;#160; The basic architecture is as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WhereisEd_114C4/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="377" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WhereisEd_114C4/image_thumb_1.png" width="576" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt; The public face to WiE is presented at the site: &lt;a href="http://www.wiecommunity.com"&gt;http://www.wiecommunity.com&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WhereisEd_114C4/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="377" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WhereisEd_114C4/image_thumb.png" width="578" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You might note the references to George Curious and Thomas Engine in the list of Friends.&amp;#160; These are test users, inspired by Olivier's children's interests ;-).&lt;/p&gt;  &lt;p&gt;When either Olivier or I are active, you can observe our location and a trace of our route:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WhereisEd_114C4/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="326" alt="image" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/WhereisEd_114C4/image_thumb_2.png" width="575" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Please bear in mind that this project is a work in progress, with numerous minor details still being worked out.&amp;#160; If you have any comments or suggestions, please let me know.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:dea4ecbc-0952-4756-a5b6-4977d327aaae" 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/WiE" rel="tag"&gt;WiE&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Where%20is%20Ed?" rel="tag"&gt;Where is Ed?&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/SQL%20Server%20Compact" rel="tag"&gt;SQL Server Compact&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL%20Services" rel="tag"&gt;SQL Services&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SSIS" rel="tag"&gt;SSIS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9255356" width="1" height="1"&gt;</description></item><item><title>Working with Invalid Data and the SQL Server 2008 Geography Data Type, Part 1b</title><link>http://blogs.msdn.com/edkatibah/archive/2008/08/19/working-with-invalid-data-and-the-sql-server-2008-geography-data-type-part-1b.aspx</link><pubDate>Wed, 20 Aug 2008 04:40:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8880203</guid><dc:creator>EdKatibah</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/8880203.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=8880203</wfw:commentRss><description>&lt;h5 align="center"&gt;&amp;quot;&lt;strong&gt;Fixing&amp;quot; Polygon Ring Orientation in SQL Server 2008 using T-SQL&lt;/strong&gt;&lt;/h5&gt;  &lt;p&gt;In the last installment, I promised to try and correct invalid Geography data using FME.&amp;#160; While I am making progress on that front, I decided to take a small detour and discuss an interesting but little known behavior of the SQL Server Geometry type, polygons and data validation.&lt;/p&gt;  &lt;p&gt;One of the most common data errors when attempting to import spatial data into the Geography data type involves the ring orientation of polygons:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;A .NET Framework error occurred during execution of user-defined routine or aggregate &amp;quot;geography&amp;quot;:        &lt;br /&gt;Microsoft.SqlServer.Types.GLArgumentException: 24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Consequently, we often see inquiries about changing ring orientation in SQL Server, using T-SQL.&amp;#160; Since SQL Server does not allow polygons with the &amp;quot;wrong&amp;quot; ring orientation into the Geography data type, any solution to this dilemma must use the Geometry data type. At this point, I should note that FME 2008, when loading data into a column of type Geography, attempts to correct polygon ring orientation.&amp;#160; I say attempts, since there are edge conditions (+- 180 degree meridian and the Poles) which can derail this process.&amp;#160; The same goes for the technique in T-SQL that I am about to describe.&lt;/p&gt;  &lt;p&gt;Here is the aforementioned behavior - When executing an OGC-based method (which works on the entire geometry) on valid polygon features in the Geometry data type, SQL Server will check ring orientation.&amp;#160; If SQL Server finds outer rings oriented in a clockwise direction, it will re-orient such rings to counter-clockwise - the direction required for outer rings in the Geography data type. The same goes for inner rings (holes), which SQL Server will orient to clockwise.&lt;/p&gt;  &lt;p&gt;So, how might you take advantage of this behavior?&amp;#160; I'll use a very simple test case:&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;--     &lt;br /&gt;-- Create table with Geometry column      &lt;br /&gt;--      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;CREATE TABLE foo (      &lt;br /&gt;&amp;#160; id&amp;#160;&amp;#160; INTEGER,       &lt;br /&gt;&amp;#160; geom GEOMETRY);       &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--      &lt;br /&gt;-- Create two similar polygons with opposite ring orders       &lt;br /&gt;--       &lt;br /&gt;DECLARE @g GEOMETRY = 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))';       &lt;br /&gt;DECLARE @h GEOMETRY = 'POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))';       &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--      &lt;br /&gt;-- Persist polygons to the table       &lt;br /&gt;--       &lt;br /&gt;INSERT INTO foo (id, geom) VALUES(1,@g);       &lt;br /&gt;INSERT INTO foo (id, geom) VALUES(2,@h);       &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--      &lt;br /&gt;-- Update rows, forcing validation of spatial objects       &lt;br /&gt;--       &lt;br /&gt;UPDATE foo       &lt;br /&gt;&amp;#160; &lt;/font&gt;&lt;font face="Courier New" size="2"&gt;SET geom = geom.STUnion(geom.STStartPoint());      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--      &lt;br /&gt;-- Verify new, consistent, ring order after forced validation       &lt;br /&gt;--       &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;SELECT id,geom.ToString() FROM foo;      &lt;br /&gt;--&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;-- Results:      &lt;br /&gt;-- 1&amp;#160;&amp;#160;&amp;#160; POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))       &lt;br /&gt;-- 2&amp;#160;&amp;#160;&amp;#160; POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The key to this behavior is the the STUnion() method.&amp;#160; Since this is an OGC-based method, working on the entire geometry for a given feature, it forces polygons into the orientation required for the method - which just happens to be the one used for the Geography type (quite a coincidence, eh? ;-).&amp;#160; This method illustrated is quite efficient, keeping overhead small in the quest to achieve our goal of re-orienting the polygon rings.&lt;/p&gt;  &lt;p&gt;Since the Geometry must be valid for this to work, you might want to add the MakeValid() method to the processing stream.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;UPDATE foo      &lt;br /&gt;&amp;#160; SET geom = geom.MakeValid().STUnion(geom.STStartPoint());&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It is important to note that a MakeValid() on an already valid polygon geometry will not change ring orientation, hence the need to &amp;quot;force&amp;quot; a complete validation pass with the OGC-based method (STUnion, in this case).&lt;/p&gt;  &lt;p&gt;To finish up this exercise, let's move the Geometry data to Geography data in a sister table.&amp;#160; Before doing this, please bear in mind that this approach is naive in that it does not accommodate several potential edge conditions.&amp;#160; Never-the-less, this approach should work in many cases.&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;--     &lt;br /&gt;-- Create table with Geography column      &lt;br /&gt;--      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;CREATE TABLE gfoo (     &lt;br /&gt;&amp;#160; id&amp;#160;&amp;#160; INTEGER,      &lt;br /&gt;&amp;#160; geog GEOGRAPHY);      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--     &lt;br /&gt;-- Convert from Geometry to Geography using Well Known Text      &lt;br /&gt;--      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;INSERT INTO gfoo      &lt;br /&gt;&amp;#160; SELECT foo.id, GEOGRAPHY::STGeomFromText(foo.geom.STAsText(),4326)      &lt;br /&gt;&amp;#160; FROM foo;      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;--     &lt;br /&gt;-- Convert from Geometry to Geography using Well Known Binary      &lt;br /&gt;--      &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;INSERT INTO gfoo      &lt;br /&gt;&amp;#160; SELECT foo.id, GEOGRAPHY&lt;/font&gt;&lt;font face="Courier New" size="2"&gt;::STGeomFromWKB(foo.geom.STAsBinary(),4326)     &lt;br /&gt;&amp;#160; FROM foo;      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;A special thanks to IsaacK and BobB for suggestions and assistance with the SQL syntax...&lt;/em&gt;&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f8a10948-ee82-45b0-82fc-d9b4a681c34f" 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/Spatial" rel="tag"&gt;Spatial&lt;/a&gt;,&lt;a href="http://technorati.com/tags/polygon" rel="tag"&gt;polygon&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ring%20orientation" rel="tag"&gt;ring orientation&lt;/a&gt;,&lt;a href="http://technorati.com/tags/geometry" rel="tag"&gt;geometry&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;/div&gt;  &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8880203" width="1" height="1"&gt;</description></item><item><title>GeoWeb 2008 Conference Dinner Cruise Photos (and SQL Server 2008 Spatial ;-)</title><link>http://blogs.msdn.com/edkatibah/archive/2008/07/25/geoweb-2008-conference-dinner-cruise-photos-and-sql-server-2008-spatial.aspx</link><pubDate>Fri, 25 Jul 2008 17:06:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8772222</guid><dc:creator>EdKatibah</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/edkatibah/comments/8772222.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edkatibah/commentrss.aspx?PostID=8772222</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/_D3C1342.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="_D3C1342" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/_D3C1342_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt; On the Wednesday night GeoWeb 2008 dinner cruise around Vancouver harbor, several folks who had forgotten their cameras (and 1 who had broken their camera) noted that I was busy taking photos and asked if they could be made available. I am happy to report that I have successfully uploaded the photos to my &lt;a href="http://cid-d2bc0d267d48ef9f.skydrive.live.com/browse.aspx/GeoWeb%202008%20Dinner%20Cruise%20Photos"&gt;Skydrive&lt;/a&gt; account. There you will find 13 zipped archives, each containing approximately 7 to 8 images (GW-1.zip,...,GW-13.zip). Why 13 zip archives, you ask? Because Skydrive does not allow any single file to be over 50 megabytes in size. The 94 images I took vary in size from 4.96 to 7.70 megabytes each, for a total size of 590 megabytes - thus the need for 13 archives. In the interest of time, I did not perform any significant editing, removing only the obvious duds &amp;#8211; camera shake on a couple and some &amp;#8220;misses&amp;#8221; during the fireworks display. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/_D3C1379.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="_D3C1379" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/_D3C1379_thumb.jpg" width="244" border="0" /&gt;&lt;/a&gt;I just put up another folder containing the &lt;a href="http://cid-d2bc0d267d48ef9f.skydrive.live.com/browse.aspx/GeoWeb%202008%20Dinner%20Cruise%20Photos/Individual%20Photos" target="_blank"&gt;individual photos&lt;/a&gt;, if you want to browse before downloading the archives or if you just want a few images.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/_D3C1427.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="_D3C1427" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/_D3C1427_thumb.jpg" width="163" border="0" /&gt;&lt;/a&gt; The last question might you ask is how these images could possibly relate to SQL Server 2008 Spatial? Easy - each image has the latitude and longitude (or longitude and latitude, depending on your persuasion&amp;#8230;) and UTC time encoded in the EXIF image metadata. This was accomplished through the use of my &lt;a href="http://www.di-gps.com/di-GPS/basic_1.htm" target="_blank"&gt;di-GPS&lt;/a&gt; equipped Nikon D300 camera. Back at the hotel room, I loaded the dinner cruise images into SQL Server 2008 (Geography data type for image location, DateTimeOffset data type for date/time/time zone, varbinary(max) data type with FileStream option for the image itself and I used the Sparse Columns option for the plethora of GPS-related data columns). With the location and image data for each photo in SQL Server 2008, Virtual Earth was used to display the location of the images:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/clip_image002_2.jpg"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="385" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/edkatibah/WindowsLiveWriter/GeoWeb2008ConferenceDinnerCruisePhotosan_138B4/clip_image002_thumb.jpg" width="454" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy.&lt;/p&gt;  &lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:85154c55-c9bd-46b8-a029-2dd8432718d1" 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/GeoWeb%202008" rel="tag"&gt;GeoWeb 2008&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Photos" rel="tag"&gt;Photos&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8772222" width="1" height="1"&gt;</description></item></channel></rss>