Home > Geospatial, SQL Server 2008R2, SQL Server 2012 > Spatial, Geography, and Geometry. Oh my! – Geospatial Data Part 1

Spatial, Geography, and Geometry. Oh my! – Geospatial Data Part 1

Geography and Geometry.  Gives me flashbacks to high school.  Though those would lead to interesting stories, today we’re here to discuss Spatial within SQL Server.   There are a lot of different uses for spatial, but it all boils down to the ability to represent SQL Server data on a map, either 3D or 2D.  Shall we begin?

Spatial data analysis is a complex subject area, encompassing a vast range of academic disciplines, including geophysics, mathematics, astronomy, and cartography.  Luckily, we don’t need to understand all these subjects to perform spatial data analysis within SQL Server.

Spatial data describes the position, data, shape and orientation of an object in space.  What we’re working with is geospatial data, which can describe the properties of objects on the earth, such as a building or a mountain.

What are some of the uses of spatial data?  Here’s a sample:

  • Analysing regional, national or international trends
  • Deciding where to place a new facility based on proximity to customers or competitors
  • Allowing customers to track delivery of a package
  • Optimizing distribution networks to increase efficency
  • Reporting data on a map rather than in grid or table format
  • Providing location-based services, i.e. list of nearby restaurants for a given address

SQL Server supports three primary types of geometry that can be used to represent spatial information:  Points, Linestrings, and Polygons.


point is the most fundamental type of geometry, and is used to define a singular position in space.  A point is zero-dimensional, meaning it doesn’t have an area or a length.  It is just a single dot.

When using geospatial data to define features, a point is used to represent an exact location, like a street address or a city.


If one defines two points, we can then draw a straight line between them, which defines a linestring.  Linestrings consist of a two or more points and the line segments that connect them.  Linestrings are one-dimensional, meaning they have a length, but no area.  There are two types of linestrings:

  1. Simple Linestring is one in which the path drawn between the points does not cross itself.
  2. A Closed Linestring is one that starts and ends at the same point (making a shape).

A linestring that is both simple and closed iks known as a ring.  Take note that although this forms a perimeter, it still has no area, as we are just talking about the line itself, not the data within.

Linestrings are commonly used to represent roads, rivers, or contours of the earth.


A polygon is defined by a boundary of connected points that forms a closed linestring, called the exterior ring.  The difference is that the polygon, along with defining all points on the lines, defines all points within the linestring as well.  It is the entire area encompassed by the exterior ring.

Each polygon may only have one exterior ring.  No more, no less.  Internal Rings are closed linestrings within a polygon create a “hole” or area within the closed linestring that does not get included int he polygon.  Polygons are two-dimensional – consisting of an area and associated length (of the linestrings).

Polygons are frequently used in spatial data to represent geographical areas, such as islands, lakes, political jurisdictions, or nation/state borders.

This is the basic framework of two-dimensional geospatial data analysis.  Next time, we’ll cover the three-dimensional aspects, or the “coordinate system”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: