STGeometryTypes: Extracting all geometry type string values from complex geometry

Ever needed to extract a textual description of all geometry types in a single geometry/geography in SQL Server 2008 inluding all sub-elements? Recently I had cause to do so and created the following function that implements this need. Now let’s test it against a selection of all possible geometry types I hope this function isRead More

Vectorising geometry objects in SQL Server 2008

I demonstrated in this article the usefulness of having a vectorising function in one’s spatial database kitbag (there are GetVector functions in my CENTROID and GEOM packages – in particular the GetVector function is vital to the implementation of the algorithm in my CENTROID.SDO_CENTROID function). So, I have also added one to my SQL ServerRead More

STMBR2Geometry/STMBR2Geography functions

Oracle has a polygon geometry type (non-standard) called an optimized rectangle. To define one all one has to do is supply it with the lower-left and upper-right coordinates. This is a much easier thing to do than having to supply 5 coordinates in anti-clockwise order. PostGIS also has a bunch of bounding box functions thatRead More

Extracting geometry types from geometry/geography objects in SQL Server 2008

I have pointed out in another blog that the result of an STIntersection() between two polygon objects could result in an object that is not a polygon or multipolygon. Intersection GEOMETRYCOLLECTION (POLYGON ((100 200, 180 300, 100 300, 100 200)), LINESTRING (100 200, 100 75), POINT (100 0)) Note, the the result is a geometryRead More

Using SQL Server XML and Spatial to import VicMap seed/Incremental Update Format (IUF) data (Part 3)

This is the 3rd and last blog post about processing VicMap IUF XML data. (The 6 month delay is because I lost a draft of this article, and have been doing other things.) While much in this and the previous articles are about an Australian XML data format, the principles outlined remain the same. ThisRead More

Getting the number of coordinate dimensions of a geometry/geography object in SQL Server 2008

The OGC standard has an STDimension() method defined on geometry/geography objects and this is implemented in SQL Server 2009. This function returns the inherent (or topological) dimensionality of an object: for a point this is 0; for a linestring this is 1; and for a polygon this is 2. name dim Point 0 LineString 1Read More

STDumpPoints: A Function that Dumps the Vertices/Points in a geometry

I often find I need to manipulate the points of a geometry/geography object directly in SQL. Oracle has the neat TABLE function mdsys.sdo_util.GetVertices( sdo_geometry ) for this. Since SQL Server 2008 does not have such a function I found I had to write it myself. I prefer to program in TSQL using the OGC geometry/geographyRead More

toGeography and toGeography Conversion Functions for SQL Server 2008 Spatial

I have been doing some SQL Server 2008 programming lately and have come across the fact that TSQL does not allowing a programmer to create overloaded functions. This is an issue, when programming SQL Server 2008 Spatial, because of use of its implementation of two different data types for geodetic and projected data: geography andRead More

Write text file with spatial data from SQL Server 2008

Trivial I know, but here is a method for writing the result of a query (select) to a text file where the query contains either geometry or geography data. To do this we will use the xp_cmdshell stored procedure to call the external sqlcmd tool. To do this, first, we must allow SQL Server toRead More