World Borders Dataset

The spatial results tab in SQL Server Management Studio is a useful tool to quickly visualise the geography or geometry data returned by a SELECT query. However, it does not provide any additional context surrounding that data - Points, LineStrings, and Polygons are displayed as abstract shapes against an infinite white background.

When visualising items of geospatial data - data that relates to features on the earth's surface - it is helpful to overlay that data against a background map so that features may be placed in context.

In this post, I'll show you how to create an item representing a simple map of the world that can be used as a background to any results displayed in the SQL Server Management Studio Spatial Results tab. First, download and execute one of the following two queries to create a table containing the background polygons:


Great Britain (geometry datatype, SRID 27700)

World Borders (geograpy/geometry datatypes, SRID 4326)

To include the background map in your query, simply add a UNION ALL SELECT to the background shape in your query, as follows:

DECLARE @BermudaTriangle geography
SET @BermudaTriangle = geography::STPolyFromText(
  'POLYGON((-66.07 18.45, -64.78 32.3, -80.21 25.78, -66.07 18.45))',
  4326)
 
SELECT @BermudaTriangle
UNION ALL SELECT geog FROM World_Borders
The result is as follows:

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options