Working with geometry

Our first example shows how to define and store shapes representing town districts and avenues using the geometry data type and then demonstrates how to query this data to return a list of the avenues that run through each district. This little one-horse town has only three districts and two main avenues and is small enough to be expressed on a planar (flat) surface using the geometry data type. As we progress through the example, you’ll learn how to use a number of common geospatial methods with this data type.

Figure 9-3 shows the shapes that map out the town and the xy-coordinates for the points of each shape. The three districts are polygons (closed shapes), and the two avenues are line strings. We will store these shapes ...

Get Programming Microsoft® SQL Server™ 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.