Katmai Spatial - Whats a dimension? - Simon Sabin UK SQL Consultant's Blog

Katmai Spatial - Whats a dimension?

When you read the specs for the spatial stuff (BOL has some incorrect links) some of the methods talk about min and maximum geometry dimensions. I must have been doing too much analysis services stuff and for the life of me I couldn't figure out what a dimension was in this context.

On reading the specs I had a homer moment "DOH!!!".

Of course the dimensions are whether it is 1D, 2D, 3D (remember Jaws ?) etc.

So how does this relate to geometries and spatial stuff.

There are 3 base geometries in SQL 2008, a point, a line and a polygon. In Katmai the spatial is only defined in 2 dimensions (ok so each geometry has a z and an m value but these aren't really used).

So the maximum dimensions in Katmai is 2, i.e. we are dealing with a flat surface (even the Geography stuff is really flat there is no concept of height).

In this situation a point has 0 dimensions (no length or area), a line has 1 dimension (no area) and a polygon has 2 dimensions.

Why is this inportant? Well the spatial methods often only work with or return geometries with certain dimensions. i.e. the method STCrosses returns true if the intersection of the geometries has a lesser dimension than the maxium dimension of the two geometries, and the intersection only contains points inside each geometry. So in english, if you have a polygon (2D) this will return False, because when 2 polygons overlap the intersection is another polygon (2D) 2D=2D and so we get false. You can overlap polygons on their edges where the intersection is just a line. But in this case the points of the line are not inside the 2 polygons but rather on the edge.

Compare this with STIntersection that returns true if either geometries share the same points. No matter the dimension of the intersection.

Finally STContains only applies to polygons (generally). A line only has 1 dimension and so can't contain anything (well it can contain another line or a point if the line or point are just a part of the line). My point here is that even if a line is closed (start and end points the same), it only has 1 dimension and so does not cover the area that it has enclosed, and so any geometries within this area are not contained in the line. You can create a polygon from that closed line, in which case this polygon will contain any geometries that exist in the enclosed space.

More on functions later.



-
Published 12 December 2007 15:06 by simonsabin

Comments

No Comments