• Skip to content
  • Skip to primary sidebar
  • Skip to footer

Mindy Curnutt and Associates

  • Services
  • About
  • Blog
Home » Do You Want to Build a Snowman?

December 1, 2016 By Mindy Curnutt

Do You Want to Build a Snowman?

I’ll be teaching a session on Spatial Data coming up this weekend at SQL Saturday, Washington DC.  In the recent past, at the end of my presentation we have a little fun and use spatial methods to render a drawing of Hillary and Donald using only T-SQL. Honestly, I’m getting rather tired of that story, and I’m ready to move on to something much more lighthearted.

So – I decided to replace that section of my presentation with a drawing of Olaf.

JPG that I started out with.
JPG that I started out with.

I used the technique created and outlined clearly by Alex Whittles in this blog post: http://www.purplefrogsystems.com/blog/2011/05/sql-server-art-using-spatial-data/

  1. Convert a lineart image to a bitmap
  2. Convert bitmap to a vector (vectormagic.com)
  3. Use Excel workbook for formatting
  4. Paste in SQL

I took the JPG above and opened it up in Adobe Photoshop and then converted and saved it as a BMP file. The result of that transformation left me with an image that looked like this (pretty much looks exactly the same…)

olaf
Bitmap Olaf

I used the vectormagic site to convert the BMP to an EPS. For some reason WordPress will not let me upload and share an EPS, so I changed the extension to TXT. I have attached that here so that you can see what it looks like. You’re going to open the EPS file in Notepad anyway in order to work with the contents.

Olaf EPS file contents: Olaf EPS File Contents

I took the contents of the EPS and dropped it into the excel workbook that Alex Whittles created. You can see how that looks here: Olaf Excel Workbook

I added an additional step of blending all of the vector lines together using the UnionAggregate spatial method. Then I combined the result with a Union of itself with a little buffering to make the drawing darker and more clear.  The resulting SQL statement that draws Olaf in SSMS is here (just rename to an .SQL extension):  Draw Olaf Using TSQL

The result should look something like this:

Spatial Olaf
Spatial Olaf

Now, as one person recently pointed out in a session I taught – “what is the business case for this?”. You know, I can’t think of one other than having fun while learning. I have used this technique to prank a few folks, emailing them a query to run that draws their own face. Nothing wrong with making learning fun if you ask me.  Happy coding.

Mindy Curnutt

Mindy Curnutt is a five time Microsoft Data Platform MVP with over 20 years of experience working with Database Solutions. She specializes in Performance Tuning and Architecture. She speaks regularly across North America at Local User Groups, SQL Saturdays and Conferences.

Filed Under: Spatial Data Tagged With: excel, microsoft, spatial data, sql, sql server, Transact SQL language

Reader Interactions

Primary Sidebar

Categories

  • Awards
  • Azure
  • MDS
  • Power BI
  • Powershell
  • Spatial Data
  • SQL
  • What I Learned Today

Archives

  • December 2018
  • November 2018
  • September 2018
  • June 2018
  • May 2017
  • April 2017
  • December 2016
  • November 2016
  • September 2016
  • May 2016
  • April 2016

Recent Comments

  • Twitter Campaign/Brand Management In Power BI – Curated SQL on Power BI, Twitter and the Old Settlers Music Festival

Recent Posts

  • Live! 360 Speaker
  • BOOK PUBLICATION: SQL Server 2017 Administration Inside Out
  • Power BI Class on October 11 – 2018
  • My Article at IT Pro Today – Azure Cosmos DB vs. SQL Server
  • Restoring a SQL Backup from Azure Blob Storage

Footer

Resources Pages

Volunteer Activity
Books and Presentations
Spatial Data Resources
Learning Resources
Speaking Engagements

Privacy Policy

Site Map

Join My Newsletter

Subscribe to my mailing list

* indicates required



Copyright Mindy Curnutt© 2021